Holen Sie sich den Kartenschlüssel von Index Kotlin
map.keys().toArray()[0]
Stockholm
map.keys().toArray()[0]
fun main(args: Array<String>) {
var capitals = hashMapOf<String, String>()
capitals.put("Nepal", "Kathmandu")
capitals.put("India", "New Delhi")
capitals.put("United States", "Washington")
capitals.put("England", "London")
capitals.put("Australia", "Canberra")
val result = capitals.toList().sortedBy { (_, value) -> value}.toMap()
for (entry in result) {
print("Key: " + entry.key)
println(" Value: " + entry.value)
}
}