Functional quicksort