The title says it all.
total = {\"Bob\"=>37, \"Alice\"=>42, \"Carl\"=>42}
I want to sort it by value, and then by key, but with th
If you're using ruby >= 2.1, then just call to_h on sorted array of tuples:
to_h
total = {"Bob"=>37, "Alice"=>42, "Carl"=>42} total.sort_by{|k, v| [v, k]}.to_h
Else call Hash.new:
Hash.new
total = {"Bob"=>37, "Alice"=>42, "Carl"=>42} Hash.new total.sort_by{|k, v| [v, k]}.to_h