I know that Rails has sorting methods built into ActiveRecord, but I am just writing a plain-old ruby script and would love to sort the records from an array by date.
The date would be stored in one of the cells of the multi-dimensional array.
What’s the best way for me to approach this, so I can get to the point where I just do sort_by_date and I indicate either ASC or DESC?
I don’t have to use the method sort_by_date, but the idea is I would like to be able to easily call a method on the collection and get the results I want.
Thoughts?
Something like this?
A multi-dimensional array is just an array of arrays, so call this method on the ‘dimension’ you want to sort.