Ruby hash key sort
sorted_map = {}
# asc
unsorted_map.sort.each {|key, val| sorted_map[key] = val}
# desc
# unsorted_map.sort.reverse.each {|key, val| sorted_map[key] = val}
Written by ryooo321
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Related Tags
#ruby
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#