functioning qsort