The qsort_r function is the reentrant version of qsort. qsort_r is identical to qsort except that the comparison function compar takes a third argument. A pointer is passed to the comparison function via arg.