随手写了个归并排序的代码,不需要额外写merge函数
def merge_sort(data):
if len(data) > 1:
result = list()
left = merge_sort(data[:(len(data)//2)])
right = merge_sort(data[(len(data)//2):])
while len(left) > 0 and len(right):
if left[0] > right[0]:
result.append(right.pop(0))
else:
result.append(left.pop(0))
result += left
result += right
return result
else:
return data