changed qsort to BLI_qsort_r