Quicksort optimization