Write a code , quick sort
时间: 2024-05-08 08:17:58 浏览: 63
quick sort
Sure, here's an implementation of the quick sort algorithm in Python:
```
def quick_sort(array):
length = len(array)
if length <= 1:
return array
else:
pivot = array.pop()
items_greater = []
items_lower = []
for item in array:
if item > pivot:
items_greater.append(item)
else:
items_lower.append(item)
return quick_sort(items_lower) + [pivot] + quick_sort(items_greater)
```
This function takes an array as input and returns a sorted version of the array using the quick sort algorithm.
阅读全文