Created
June 14, 2014 22:36
-
-
Save jonathanhudak/389f21901ae647ae627a to your computer and use it in GitHub Desktop.
sort array of hashes
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
arrayOfHashes = [{'count' => 5}, {'count' => 3}, {'count' => 8}]; | |
puts arrayOfHashes.sort_by { |hash| hash[:count]} |
If you change hash[:count] to hash['count'] this works.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue here is that :count is not the same as 'count'.