partitioning method for quicksort