From: Robert Klemme Date: 2009-03-19T00:58:40+09:00 Subject: Re: Complex sort of matrix possible, e.g. like Excel? 2009/3/18 Gary Wright : > > On Mar 18, 2009, at 6:16 AM, Robert Klemme wrote: >> >> You can as well do >> >> arr.sort_by {|a,b| [a[0]<=>b[0], b[1]<=>a[1]]} > > This doesn't seem quite right to me.  Shouldn't it be: > > arr.sort_by { |item| [item[0], item[1]] } Yes, you're right. Copy & paste error. However, your solution is not fully correct either because it does not take into consideration that order of the second column should be reversed. So you'd have to do arr.sort_by { |item| [item[0], -item[1]] } Thanks for the heads up! robert -- remember.guy do |as, often| as.you_can - without end