def merge(left, right):
    """Merge helper for the merge sort."""
    final = []
    leftcount = 0
    rightcount = 0

    while leftcount < len(left) and rightcount < len(right):
        if left[leftcount] < right[rightcount]:
            final.append(left[leftcount])
            leftcount += 1
        else:
            final.append(right[rightcount])
            rightcount += 1

    while leftcount < len(left):
        final.append(left[leftcount])
        leftcount += 1

    while rightcount < len(right):
        final.append(right[rightcount])
        rightcount += 1

    return final