简单快速排序 (python)
作者:互联网
def q_sort(arr):
if len(arr) < 2:
return arr
else:
pivot = arr[0]
less = [i for i in arr[1:] if i <= pivot]
greater = [i for i in arr[1:] if i > pivot]
return q_sort(less) + [pivot] + q_sort(greater)
标签:sort,arr,return,greater,less,python,pivot,排序,快速 来源: https://blog.csdn.net/weixin_44495162/article/details/121029610