请帮我写一份快速排序的代码
时间: 2023-03-14 19:05:25 浏览: 85
示例代码:
def quickSort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quickSort(left) + middle + quickSort(right)
阅读全文