def merge(left_sub_array, right_sub_array):
    """Merges the sub-arrays together from smallest to biggest element"""
    merged = []
    left_index = 0
    right_index = 0

    # go through both sub-array from left to right appending always the smallest element to the merged array
    while left_index < len(left_sub_array) and right_index < len(right_sub_array):
        if left_sub_array[left_index] < right_sub_array[right_index]:
            merged.append(right_sub_array[right_index])
            right_index += 1
        else:
            merged.append(left_sub_array[left_index])
            left_index += 1

    # add what is left in one of the arrays
    merged += left_sub_array[left_index:]
    merged += right_sub_array[right_index:]

    return merged