python的快速排序代码

以下是 Python 中的快速排序代码:

``` def quick_sort(array): if len(array) <= 1: return array else: pivot = array[0] less = [x for x in array[1:] if x <= pivot] greater = [x for x in array[1:] if x > pivot] return quick_sort(less) + [pivot] + quick_sort(greater) `

猜你喜欢

转载自blog.csdn.net/weixin_42600128/article/details/129510748
今日推荐