use reentrant qsort_r where available

- this avoids one TLS access per comparison