Create an array of objects ordered based on the attribute of the child class
I have a class
class Job < ActiveRecord::Base has_many :stops end
class has attribute
datetime :arrival time
What is a concise way to get an array of all jobs ordered by early arrival time at related stops?
If job_1 has two stops, one with an arrival time of 4pm and one with an arrival time of 5pm.
And job_2 has two stops, one with an arrival time of 3pm and one with an arrival time of 6pm.
array: [job_2, job_1]
I can achieve this, but in a cumbersome way that involves looping and temporarily storing values.
source to share