Challenge 3: Sorting Custom Objects — Solution class Temperature include Comparable attr_reader :celsius def initialize(celsius) @celsius = celsius end def <=>(other) celsius <=> other.celsius end def to_s "#{celsius}°C" end end readings = [ Temperature.new(21), Temperature.new(-5), Temperature.new(100), Temperature.new(0), Temperature.new(37) ] sorted = readings.sort puts sorted.map(&:to_s).join(", ") =begin Output: -5°C, 0°C, 21°C, 37°C, 100°C Notes: - readings.sort is called with no block and no explicit comparison logic passed in at all — Array#sort automatically uses each element's <=> method when nothing else is provided. - Because Temperature defines <=> (and includes Comparable, which relies on it), .sort produces a correctly ordered array with zero extra code written specifically for sorting. - .map(&:to_s) uses the Symbol#to_proc shorthand from Course 1 Chapter 8 to convert each Temperature into its string form for a readable one-line printout, using the to_s override defined above. =end