From: Paul Date: 2007-03-20T05:00:14+09:00 Subject: Re: Sorting Dates and Times in an array On Mar 19, 1:21 pm, Robert Klemme wrote: > I think this does not meet the OP's requirements (because of descending > date). > > epoch = Date.new(0) > @date_array.sort_by {|dt,tm| [epoch - Date.parse(dt), Time.parse(tm)]} > > Substraction with epoch will make date components negative and thus lead > to descending ordering. > Hello Robert, I tried this but I get the following errors: irb(main):003:0> epoch = Date.new(0) ArgumentError: wrong number of arguments (1 for 0) from (irb):3:in `initialize' from (irb):3 irb(main):005:0> @date_array.sort_by {|dt,tm| [epoch - Date.parse(dt), Time.parse(tm)]} NoMethodError: undefined method `parse' for Date:Class from (irb):5 from (irb):5:in `sort_by' from (irb):5 Am I missing a 'require' or something to make your lines work?