Sort an array with reentrancy, following the upcoming POSIX prototype.
cf. POSIX qsort_r
References arg, compar, and state.