On 2007-01-09 15:53:13 +0100, "Jan Svitok" <jan.svitok / gmail.com> said: > On 1/9/07, Josselin <josselin / wanadoo.fr> wrote: >> On 2007-01-09 15:29:43 +0100, Josselin <josselin / wanadoo.fr> said: >> >> > I can sort an array like that : >> > >> > results = rs.sort_by{|p| p.km} >> > >> > but I tried to add a scrond sorting criteria like that : >> > >> > results = rs.sort_by{|p| p.km, p.updated_at } >> > >> > and I got obviously an error ... parse error, unexpected '}', >> > expecting tCOLON2 or '[' or '.' >> > >> > canot find the correct writing.. >> > >> > appreciate any help... >> > >> > thanks >> > >> > joss >> >> thanks to both of you... and HNY%2007 (Dry version of Happy New Year >> 2007) ;-)) >> >> I forgot to ask about a DESC sort.... p.km is Ascending and >> p.updated_at should be DESC.. >> >> I am not sure that is possible (at least not documented.....) >> >> joss > > results = rs.sort_by{|p| p.km, -p.updated_at } # if updated_at is Numeric > > or > > results = rs.sort { |a,b| [a.km, b.updated_at] <=> [b.km, a.updated_at] } thanks , 'updated_at' is a string ( "2007-01-04 13:48:30") I try to understand the writing... why the first parameter will be Ascending and the second Descending ... how would you write it, if both parameters shoudl be Descending ? Joss