maybe we could add a naive topN based on sort + slice last N elements, so clients can start using that, and then they'd benefit when a proper topN is in stdlib
Nah, feel free to write one and submit a Nimble package. Translating standard textbook algorithms to Nim is not hard and probably can also be done by AI.
FWIW, if you're going out to the nimbleverse already, it's already in adix/lptabzand for small key spaces (like char or short-indexable) in adix/ditab(as an iteratorover the topByVal, not as a proc) { no need there to build a seq(well, a seqbeyondthe heap-structured seqalready built in heapqueue) }.