computing number of inversions during merge sort implemented