python 递归+快排
程序员文章站
2022-05-05 17:37:32
...
def quicksort(a):
if (len(a) < 2):
return a
else:
t = a[0]
high = []
low = []
for i in range(1, len(a)):
if (a[i] > t):
high.append(a[i])
else:
low.append(a[i])
return quicksort(low) + [t] + quicksort(high)
print(quicksort([1, 2, 7, 4, 5, 9]))
上一篇: 洗了缩小了...
下一篇: python 动态规划