-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU import Data.List(sortBy,elemIndex) import Data.Ord(comparing) main = getContents >>= putStrLn . unwords . solve . tail . words where solve xs = sortBy cardSort xs cardSort xs ys = comparing cardOrder xs ys cardOrder (s:n:_) = suitValue + numValue where suitValue = case elemIndex s "DCHS" of {Just x -> x} numValue = case elemIndex n "A23456789TJQK" of {Just x -> x}