The docstring of compact states that result will be "sorted ascendingly according to values", but it seems like there is a sortOn (Down . snd) in the code that causes the result to actually be sorted in descending order of probability.
|
compact = sortOn (Down . snd) . Map.toAscList . Map.fromListWith (+) |