cider

jumar 2025-12-23T09:39:57.569029Z

In inspector, how can I sort a collection of maps by a specific key? Say I have a collection like this which I want to sort by thread-cpu-time-ms (in a descending order)

Class: clojure.lang.PersistentVector
Count: 100

--- Contents:
   0. {:thread-id 1, :thread-cpu-time-ms 21302.194, :thread-cpu-user-time-ms 20140.73}
   1. {:thread-id 2, :thread-cpu-time-ms 14.651, :thread-cpu-user-time-ms 13.047}
   2. {:thread-id 3, :thread-cpu-time-ms 5.7, :thread-cpu-user-time-ms 4.601}
   3. {:thread-id 4, :thread-cpu-time-ms 0.019, :thread-cpu-user-time-ms 0.007}
   4. {:thread-id 12, :thread-cpu-time-ms 31.075, :thread-cpu-user-time-ms 18.786}
   5. {:thread-id 13, :thread-cpu-time-ms 7282.53, :thread-cpu-user-time-ms 2270.071}
   6. {:thread-id 14, :thread-cpu-time-ms 131163.027, :thread-cpu-user-time-ms 123516.705}
...
I'm trying S (for "sort maps") but it doesn't seem to be doing anything.

oyakushev 2025-12-29T14:56:29.352539Z

S for sort maps means that a map itself will be sorted by keys (when a map is inspected). There is nothing in the inspector for what you asked for, you would need to do the sorting manually before inspecting (e.g. inspecting (sort-by :thread-cpu-time-ms > data))

👍 1