h = %w{D C H S}.map.with_index{|a, b|[a, b]}.to_h _h = h.invert d = %w{A 2 3 4 5 6 7 8 9 T J Q K}.map.with_index{|a, b|[a, b]}.to_h _d = d.invert gets puts gets.chomp.split(" ").map{|s| [h[s[0]], d[s[1]]]}.sort.map{|s| _h[s[0]] + _d[s[1]]}.join(" ")