From: Howard Roberts Date: 2008-07-22T19:31:48+09:00 Subject: Re: Grouping/Sorting an Array of objects Pe単a, Botp wrote: > prev_date=nil > @data.sort_by do |item| > t,ampm = item.time.split > hr,min = t.split ":" > hr = "0"+hr if hr.size==1 > timenew = ampm+hr+min > [item.date, timenew, item.class.to_s] > end.each do |item| Brilliant! > There's some clobbering of time in there since i arranged by time too :) I can adapt my app for that. > Is that ok? > Kind regards -botp -botp, This is superb! I was reluctant to ask for help on this at all because it sounded so much like I was asking "write my code for me." But I would have never gotten that, because I did not know you could use sort_by in such a way-- passing an array as the last line of the block. It is exactly what I needed and I am most grateful-- for the clearer understanding (and the code :) Thank You, Howard -- Posted via http://www.ruby-forum.com/.