FRom http://larsson.dogma.net/qsufsort.c
tidy