题解 | #排序#
排序
http://www.nowcoder.com/practice/2baf799ea0594abd974d37139de27896
Solution 1: Quick Sort--Programming with Python
#O(nlogn)
class Solution:
def MySort(self , arr ):
if (len(arr)<2):
return arr
else:
base=arr[0]
small=[i for i in arr[1:] if i<=base]
large=[i for i in arr[1:] if i>base]
return self.MySort(small)+[base]+self.MySort(large)