def sort_and_count_split_inversions (left, right):
    """
        Counts the number of inversions accross left and right.

        An inversion is any pair (i,j), i from left array and j from right
        array, such that i > j.

        Params:
            left: sorted list
            right: sorted list

        Return:
            [{list}, {int}] - sorted array and invertion counter
    """
    n = len(left)
    m = len(right)
    out = []
    i = 0
    j = 0
    count = 0

    while i < n and j < m:
        if left[i] <= right[j]:
            out.append(left[i])
            i += 1
        else:
            out.append(right[j])
            j += 1
            # Count an inversion when an element in the right array
            # is larger the the one in the left array.
            count += n - i

    if i == n:
        out.extend(right[j:])
    elif j == m:
        out.extend(left[i:])

    return [out, count]