in reply to Schwartzian Transform and memory allocation.

Instead of creating a temporary array reference, you can instead prepend the sort key to the data itself, sort that, then take the sort key off at the end, I think that's the Guttman/Rossler transform, which is a variation on the 'Schwartzian transform'. BTW, your code doesn't appear to be sorting on any particular column, it appears to just be doing a plain sort on the data.