def merge_sort(data):
'''
归并排序
:param lists:
:return:
'''
num = len(data)
if num <= 1:
return data
mid = num // 2
left = merge_sort(data[:mid])
right = merge_sort(data[mid:])
return merge(left, right)
def merge(left,right):
r, l = 0, 0
result = []
while l < len(left) and r < len(right):
if left[l] <= right[r]:
result.append(left[l])
l += 1
else:
result.append(right[r])
r += 1
result += list(left[l:])
result += list(right[r:])
return result