fun main(args: Array) { val n = readLine()!!.toInt() val cards = readLine()!!.split(" ").map { Card(it) }.sorted() println(cards.map { it.value }.joinToString(" ")) } data class Card(val value:String):Comparable { override fun compareTo(other: Card): Int { val suit = "DCHS" val idx1 = suit.indexOf(value[0]) val idxOther1 = suit.indexOf(other.value[0]) if(idx1 == idxOther1) { val number = "A23456789TJQK" val subIdx1 = number.indexOf(value[1]) val subIdxOther = number.indexOf(other.value[1]) return subIdx1.compareTo(subIdxOther) } return idx1.compareTo(idxOther1) } }