merge sort and counting inversions using merge sort