modified quicksort to run in-place