Created
October 24, 2017 00:39
-
-
Save marka2g/d50c3782641d6ec6dc276ca02141fae9 to your computer and use it in GitHub Desktop.
Order By Index
This file contains hidden or 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
| days_array = ["everyday", "school_nights", "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] | |
| def order_days(hashes) | |
| days_indexes = {} | |
| days_array.each_with_index do |item, index| | |
| days_indexes[item] = index | |
| end | |
| hashes.sort_by do |schedule| | |
| days_indexes.fetch(schedule[:day].downcase) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment