I have an array of objects in Ruby on Rails. I want to sort the array by an attribute of the object. Is it possible?
Yes, using Array#sort! this is easy.
myarray.sort! { |a, b| a.attribute <=> b.attribute }