`CountTable` from the `tables` library can also do this. I don't know how it compares speed-wise with the previous solution
The `keys()` iterator will retrieve the sorted numbers (it sorts on insert??), and the value is the number of occurrences. If you already have a sequence of data, you can use the `toCountTable()` proc to convert to a CountTable