Hi,
I have an array of objects in ruby on rails. I want to sort this array by an attribute of the object. Is it possible?
1
|
|||
|
7
|
Yes, using
|
||||||
|
4
|
Array#sort works well, as posted above:
BUT, you need to make sure that the |
||
|
3
|
I recommend using sort_by instead:
Especially if attribute may be calculated. |
||
|
1
|
|
||
|