ruby sort an object code example Example: ruby sort an object objects.sort_by {|obj| obj.attribute} # OR objects.sort_by(&:attribute)