Ascending order :
objects_array.sort! { |a, b| a.attribute <=> b.attribute }
or
objects_array.sort_by{ |obj| obj.attribute }
Descending order :
objects_array.sort! { |a, b| b.attribute <=> a.attribute }
or
objects_array.sort_by{ |obj| obj.attribute }.reverse