#思想:
#取第一个数作为基准,比第一个大的数放至右边,比第一个小的放左边
def quick_sort(quick_list):
if quick_list == []:
return []
else:
first = quick_list[0]
left = quick_sort([l for l in quick_list[1:] if l < first])
right = quick_sort([r for r in quick_list[1:] if r >= first])
return left + [first] + right
quick_list = quick_sort([12,3,4,67,8,12,9,0,45])
print(quick_list)
网友评论