Skip to content

Instantly share code, notes, and snippets.

@ozgun
Created November 19, 2012 08:28
Show Gist options
  • Select an option

  • Save ozgun/4109571 to your computer and use it in GitHub Desktop.

Select an option

Save ozgun/4109571 to your computer and use it in GitHub Desktop.
Sorting hash by value
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