Sort hash by key, return hash in Ruby

In Ruby 2.1 it is simple:

h.sort.to_h

Leave a Comment