Significant increase in sorting performance.

In my testing, a large table that previously took 50 seconds to sort
now takes ~110ms to sort.