replace rt.qsort with libc wrapper
use reentrant qsort_r where available

- this avoids one TLS access per comparison