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