From: Ralf Mueller Date: 2011-08-19T19:57:55+09:00 Subject: Re: Sorting Ruby hash by value and stored the result in hash. On 08/19/2011 09:14 AM, Bartosz DziewoƄski wrote: > Hashes are not sorted. (In 1.9.1, there's just the side effect of the > order of keys not changing randomly.) > > To convert an array like the one returned by Hash#sort_by back to > hash, use Hash[ arr ]. > > You may also try googling "ordered hash ruby", there are some > solutions. But it may be simpler to refactor your code, so it doesn'/t > need to order a hash anymore, or use two objects: regular hash + > sorted array of its keys. just an idea: After the sort_by, you could just take the ordered keys for you "sorted" hash access. regards ralf