find inversions using mergesort