<In Kotlin, how can I iterate a TreeMap in reverse...
# stackoverflow
u
In Kotlin, how can I iterate a TreeMap in reversed order? I have a TreeMap and want to iterate it in reversed order. What would be an idiomatic way to do this? val tree = TreeMap(mapOf(1 to "one", 2 to "two", 3 to "three")) tree.forEach { println(it.key) } Expected Output would be 3, 2, 1