Skip to content

Instantly share code, notes, and snippets.

@the-architect
Created July 31, 2013 15:05
Show Gist options
  • Save the-architect/6122780 to your computer and use it in GitHub Desktop.
Save the-architect/6122780 to your computer and use it in GitHub Desktop.
Reverse the order of a hash
class Hash
# reverses the order of a hash
# { a: 100, b: 200 }.reverse => { b:200, a:100 }
def reverse
self.class[to_a.reverse]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment