Refactored quicksort and mergesort.