Inversion count will be sum of inversions in left - part , right - part and number of inversions in merging
$ inv_count = _mergeSort ( $ arr , $ temp , $ left , $ mid ) ; $ inv_count += _mergeSort ( $ arr , $ temp , $ mid + 1 , $ right ) ;