From: "Y. NOBUOKA" Date: 2010-09-25T22:54:59+09:00 Subject: Re: Sort hash with keys as integer > I have problems with sorting a hash. I get this sort 1,10,2,3..... > Must be because the key is a string, right? I think that your idea is right, but I can't conclude it. Please show us your code. > How do I deal with this? How do I > make the key value into an integer? Using String#to_i method [ http://ruby-doc.org/core/classes/String.html#M000787 ], you can convert a String object to a Integer object. For instance: # you want to sort this hash hash = { "1" => "test", "2" => "aaa", "10" => "bbb" } # sort : not expectation p hash.sort { |a, b| a[0] <=> b[0] } # sort : expectation p hash.sort { |a, b| a[0].to_i <=> b[0].to_i } -- NOBUOKA Yuya