Re:An overengineered solution to `sort | uniq -c` with 25x t...
by noamteyssier on Tuesday October 28, 2025 @12:47PM
(#45735267)
Yes you're right, it's not trying to do what `sort` is doing, it's trying to reproduce the output of `sort | uniq -c | sort -n` which is a more specialized but common task.
But you're right - it will be limited by RAM in a way the unix tools are not.
I did add a test with sort using a larger buffer size to the benchmarks as well.
Which could be totally useful in itself, but not even close to what "sort" is doing.
Did you run sort with a buffer size larger than the data? Your specialized one-pass program is likely faster, but at least the numbers would mean something.
That said, I don't see what is over-engineered here. It's pretty straightforward and easy to read.