counting inversions with merge sort