`O(n log n)` is pretty wretched. One simple option is to use `fromListN` with `length`. It's kind of nasty though, and may or may not be faster in practice.