Last active
August 29, 2015 14:13
-
-
Save pepetox/48952d7855a8161754fe to your computer and use it in GitHub Desktop.
shorting an array of hash by hash prop
This file contains 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
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