sort a ruby hash

A neat way to sort a hash

my_hash.keys.sort_by {|s| s.to_s}.map {|key| [key, my_hash[key]] }

found here

Leave a Reply