quicksort with count comparision