I have to sort a list using a number of criterions (a,b,c,d) where d
“Team B”=>{:a=>0, :b=>-2, :c=>4, :d=>112 },
pp tmp
because of criterion d. Is it possible that sort_by is not
stable? Or
is there something I did wrong?Wouldn’t this be simpler ? :
h.sort_by {|k,v| [v[:a],v[:b],v[:c],v[:d]]}.reverse
Best Regards,
Fred
Full Ack,
obviously sort_by isn’t stable:
test = [[1, ‘b’], [1, ‘c’], [0, ‘a’]]
p test.sort_by{|t|t[0]}
=> [[0, “a”], [1, “c”], [1, “b”]]
(ruby 1.8.2 (2004-12-25) [i386-mswin32])
cheers
Simon