From: Olivier Renaud Date: 2007-03-20T02:29:55+09:00 Subject: Re: Sorting Dates and Times in an array Le lundi 19 mars 2007 18:25, Robert Klemme a �crit�: > On 19.03.2007 18:04, Olivier Renaud wrote: > > Instead of comparing arrays that contains one element for the date and > > another element for the time, we could have created only one Time object > > representing both : > > > > @date_array.sort_by {|ary| Time.parse("#{ary.first} #{ary.last}") } > > 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. > > Kind regards > > robert Yes you're right, I just kept in mind the instruction "sort the dates !". But I missed the subtlelty. Thanks. -- Olivier Renaud