Hey I have the below code, the output is java Sort...
# multiplatform
r
Hey I have the below code, the output is java SortedMap, is there a replacement for it in kotlin?
Copy code
val order = Status.values().asList()

statuses
    .groupingBy { it }
    .eachCount()
    .toSortedMap { t, t2 ->
        order.indexOf(t) - order.indexOf(t2)
    }
s
There is no sorted map on kotlin. You can do something like this, do verify before using it though.
Copy code
val order = Status.entries.toList()
  
  statuses
    .groupingBy { it }
    .eachCount()
    .map { it.key to it.value }
    .sortedBy {
      order.indexOf(it.first)
    }.toMap()
r
yeah thats what I ended up doing, thanks!