def my_merge(list_1, list_2, key=lambda x: x):
    """ Quick function to improve the performance of branch_and_bound
    Uses the mergesort algorithm to save the headache of resorting the
    entire agenda every time we modify it.

    Given two sorted lists and a key, we merge them into one sorted list and
    return the answer. Preference is given to the elements of the first list
    in the cases of ties
    """
    list_res = []
    while list_1 and list_2:
        if key(list_1[0]) <= key(list_2[0]):
            list_res.append(list_1.pop(0))
        else:
            list_res.append(list_2.pop(0))
    if list_1:
        [list_res.append(elem) for elem in list_1]
    elif list_2:
        [list_res.append(elem) for elem in list_2]
    return list_res