I have a hash like this:
a = { 29 => 3, 14 => 6, 13 => 2, 32 => 10 }
I want to sort a hash based on values, namely: 3,6,2,10
I can do a.values.sort
but it returns an array of only sorted values. I want to sort the actual hash, so it should return a new hash (or ideally update the original hash with the sorted one) with all the same key-value pairs, but sorted !!
source
share