a quick sort function in pthread