(arr, temp, left, mid, right)
return inv_count
Merges two sorted arrays and calculates the inversion count.

    Helper function for calculating inversions. This method is
    for internal use only.
Merges two sorted arrays and calculates the inversion count.
Merges two sorted arrays and calculates the inversion count .
def _merge(arr, temp, left, mid, right):
    """
    Merges two sorted arrays and calculates the inversion count.

    Helper function for calculating inversions. This method is
    for internal use only.
    """
    i = k = left
    j = mid
    inv_count = 0
    while i < mid and j <= right:
        if arr[i] < arr[j]:
            temp[k] = arr[i]
            k += 1
            i += 1
        else:
            temp[k] = arr[j]
            k += 1
            j += 1
            inv_count += (mid -i)
    while i < mid:
        temp[k] = arr[i]
        k += 1
        i += 1
    if j <= right:
        k += right - j + 1
        j += right - j + 1
        arr[left:k + 1] = temp[left:k + 1]
    else:
        arr[left:right + 1] = temp[left:right + 1]
    return inv_count
def _merge ( arr , temp , left , mid , right ) : i = k = left j = mid inv_count = 0 while i < mid and j <= right : if arr [ i ] < arr [ j ] : temp [ k ] = arr [ i ] k += 1 i += 1 else : temp [ k ] = arr [ j ] k += 1 j += 1 inv_count += ( mid - i ) while i < mid : temp [ k ] = arr [ i ] k += 1 i += 1 if j <= right : k += right - j + 1 j += right - j + 1 arr [ left : k + 1 ] = temp [ left : k + 1 ] else : arr [ left : right + 1 ] = temp [ left : right + 1 ] return inv_count