python快排递归
时间: 2023-11-08 17:06:04 浏览: 82
python递归实现快速排序
好的,下面是 Python 快排递归的代码:
```python
def quick_sort(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 quick_sort(left) + middle + quick_sort(right)
```
阅读全文