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?
![]() ![]() ![]() |
|
|
![]() ![]() |
|
||
![]() ![]() |
Yes, using
|
||||||
|
![]() ![]() |
Array#sort works well, as posted above:
BUT, you need to make sure that the |
||
![]() ![]() |
I recommend using sort_by instead:
Especially if attribute may be calculated. |
||