def merge(arr1: list, arr2: list) -> list:
    """Merge two arrays for merge sort

    Args:
        arr1 (list): the first array
        arr2 (list): the second array

    Returns:
        list: the merged array
    """
    merged = []

    # Compare elements for both arrays
    while arr1 and arr2:
        if (arr1[0] > arr2[0]):
            merged.append(arr2[0])
            arr2.pop(0)
        else:
            merged.append(arr1[0])
            arr1.pop(0)
    
    # Either arr1 or arr2 is empty now
    # Empty arr1
    while arr1:
        merged.append(arr1[0])
        arr1.pop(0)
    
    # Empty arr2
    while arr2:
        merged.append(arr2[0])
        arr2.pop(0)
    
    return merged