Add quicksort for duplicates