Buat dan kembalikan daftar gabungan dari semua elemen dalam urutan yang diurutkan

result = []
while list1 and list2:
    result.append((list1 if list1[-1] > list2[-1] else list2).pop(-1))

if len(list1):
    result += list1[-1::-1]
if len(list2):
    result += list2[-1::-1]

return result[-1::-1]
Wide-eyed Weevil