support BSD and GNU style qsort_r functions