Created
November 19, 2012 08:28
-
-
Save ozgun/4109571 to your computer and use it in GitHub Desktop.
Sorting hash by value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test = {"deneme1" => 2, "deneme2" => 5, "deneme3" => 1} | |
| test.values.sort.inject({}){|memo, x| memo.merge(test.key(x) => x) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment