Since Order.order_lines is really just an array, then you can use the
sort feature of an array like this:
sorted = Order.order_lines.sort {|x,y| y.quantity <=> x.quantity }
Then do
sorted.each…
Hope this helps!
Since Order.order_lines is really just an array, then you can use the
sort feature of an array like this:
sorted = Order.order_lines.sort {|x,y| y.quantity <=> x.quantity }
Then do
sorted.each…
Hope this helps!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs