From: Ammar Ali Date: 2010-11-13T02:12:31+09:00 Subject: Re: help sorting objects by their instance field On Fri, Nov 12, 2010 at 6:54 PM, Aaron Haas wrote: > Thank you guys so much for your helpful posts. I just started learning > ruby this week and it has been slow going. > >  I read the api on array's sort methods and I did not understand them. > > Does this line sort the array of persons? > > @persons.sort_by {|person| person.aLname} > > do I need to save it to a new array variable? > > order_array = @persons.sort_by {|person| person.aLname} It sorts the array itself, no need to make a copy. The documentation for sort_by is in the Enumerable mixin (which Array includes) It's at: http://ruby-doc.org/core/classes/Enumerable.html#M003120 Regards, Ammar