def merge(a: list, b: list) -> list:
    """

    :param a: left list to be merged
    :param b: right list to be merged
    :return: merged, sorted list
    """
    result = []  # initialise empty list to collect result
    # while both lists are not empty, add values to result in increasing order
    while len(a) > 0 and len(b) > 0:
        if a[0] <= b[0]:
            result.append(a[0])
            del a[0]
        else:
            result.append(b[0])
            del b[0]
    # either left or right may have elements left - consume them.
    while len(a) > 0:
        result.append(a[0])
        del a[0]
    while len(b) > 0:
        result.append(b[0])
        del b[0]
    # return sorted list
    return result