def merge_lists(all_lst):
def merge(left,right):
results = []
while left and right:
if min(left) < min(right):
results.append(min(left))
left.remove(min(left))
else:
results.append(min(right))
right.remove(min(right))
results.extend(left)
results.extend(right)
return results
if all_lst == []:
return []
elif len(all_lst) == 1:
return merge(all_lst[0],[])
else:
return merge_lists([merge(all_lst[0],all_lst[1])] + all_lst[2:])
all_lst = [[2, 7, 10], [0, 4, 6], [3, 11],[123,88,7],[12,32,4,6,7],[34,22,1],[3]]
print(merge_lists(all_lst))
>>> [0, 1, 2, 3, 3, 4, 4, 6, 6, 7, 7, 7, 10, 11, 12, 22, 32, 34, 123, 88]
My code sorts the numbers in increasing order. But why is 88 not in the correct place? Is there anything wrong with my code?