improved sort performance (needs testing)

-O3 causes miscompilation, use -O2