Siep Korteling wrote:
> Ilan Berci wrote:
> 
>> 
>> ilan
> 
> irb(main):001:0> h = {1=>2,3=>4,5=>6}
> => {5=>6, 1=>2, 3=>4}
> irb(main):002:0> h.to_a.sort
> => [[1, 2], [3, 4], [5, 6]]
> irb(main):003:0> h.to_a.sort_by {|a,b| b}
> => [[1, 2], [3, 4], [5, 6]]
> irb(main):004:0>
> 
> h.to_a.sort_by {|a,b| b} #sorts by value; the OP wants to sort by key.
> h.to_a.sort_by {|key,value| key}
> #or just
> h.to_a.sort_by {|key|key}
> 
> Regards,
> 
> Siep


array.sort sorts by key, I know that. That's what I'm trying to do, but 
it doesnt work in my case for some reason

-- 
Posted via http://www.ruby-forum.com/.