If this were perl, it'd be a job for the
Schwartzian Transform, but it's not so it depends on your data.
If the numbers you have are unique, you can build an array that has the field to sort on as the keys, and the rows of data as the values, sort the numbers and then iterate over the array of sorted numbers as keys to the array, pulling out the now sorted data.
There are a few implementations of this
here . Otherwise you may have to add a decimal place or something to each number to ensure the keys are unique.