From: Gary Wright Date: 2007-12-09T08:11:06+09:00 Subject: Re: sorting by timestamp with uneven arrays On Dec 8, 2007, at 5:03 PM, Mike Dershowitz wrote: > array.sort_by won't work becuase it's not a hash (although i tried > adding a hash and then sorting by that hash, but that didn't work > either > (got a nomethod error). > > I'm not sure why you are looking for a hash. data = [ [ "model1", "instance of 1", Time.now], [ "model2", "instance of 2", Time.now - 100] ] p data.sort_by { |x| x[2] } # => [["model2", "instance of 2", Sat Dec 08 17:15:41 -0500 2007], ["model1", "instance of 1", Sat Dec 08 17:17:21 -0500 2007]] Gary Wright