I'm about to have a need to sort an array based on auxiliary data held
in a variable that's not globally accessible, so I need a sort routine
that accepts an extra parameter and passes it through to the compare
function.
Sorting algorithm is heapsort, because it's the N log N algorithm I
can implement most reliably.