def merge(a, b):
    """ merge two already sorted lists """
    s = []
    index_a = 0;
    index_b = 0;

    while index_a < len(a) and index_b < len(b):
        if a[index_a] < b[index_b]:
            s.append(a[index_a])
            index_a += 1
        else:
            s.append(b[index_b])
            index_b += 1
    if index_a == len(a):
        s.extend(b[index_b:])
    else:
        s.extend(a[index_a:])
    return s