Merge two sorted lists

If two lists are each already sorted, you can combine them into one sorted list in a single pass. Keep a position in each list, both starting at the front. Compare the two items at those positions, copy the smaller one to the result and advance that list's position. When one list is used up, copy the rest of the other.

Write merge(a, b) that returns a new sorted list containing everything from both. Do not use sort or sorted.

merge([1, 4, 9], [2, 3, 10])  ->  [1, 2, 3, 4, 9, 10]
merge([], [1, 2])             ->  [1, 2]
def merge(a, b):
    ...