hs = Hash.new hs['A'] = gets.to_i hs['B'] = gets.to_i hs['C'] = gets.to_i puts hs.sort { |(k1,v1),(k2,v2)| v2<=>v1 }.map {|a| a[0] }