I need to sort an array of ActiveRecord objects by the value in one of the columns but am unsure of how to do this.
Example, I have an Schedule model that has a Duration column. I then have two arrays of Schedule objects OriginalList and NewList. I want to sort each of those lists by Duration. I think that I'm looking for something like: -
Schedule.find(:all,
:conditions => "schedule_id IN (select schedule_id from
#{array.each.schedule_id}",
:order => 'duration')
However, this doesn't look right at all! Not even in SQL!!
Any hints on how to do this would be appreciated.