refactor quicksort and extract partition method