Skip to content

Instantly share code, notes, and snippets.

@pepetox
Last active August 29, 2015 14:13
Show Gist options
  • Save pepetox/48952d7855a8161754fe to your computer and use it in GitHub Desktop.
Save pepetox/48952d7855a8161754fe to your computer and use it in GitHub Desktop.
shorting an array of hash by hash prop
sorted_array = myarray.sort{|p1,p2| p1[:diferencia] <=> p2[:diferencia]}
Change p1 and p2 to sort in the other order
sorted_array = myarray.sort{|p1,p2| p2[:diferencia] <=> p1[:diferencia]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment