Modified the Quick Sort to count inversions