to_do = { 'Clean car' => 5, 'Take' => 3, 'Real' => 3 }to_do.sort_by { |task, priority| [priority, task] }.each { |k,v| puts k }