refactors quicksort for greater readability