Created
September 4, 2013 09:16
-
-
Save kmelkon/6434652 to your computer and use it in GitHub Desktop.
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
@grouped = {} | |
Deal.all.each do |deal| | |
letter = deal.background.slice(0,1).upcase | |
@grouped[letter] ||= [] | |
@grouped[letter] << deal | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Calling #sort on a Hash will turn it into a nested array:
Fortunately #each is smart enough to still support
.each do |first_value_in_nested_array, second_value_in_nested_array|
on that array, so the loop will just work like it's a Hash.