mosh的java写法改Python
class Solution:
def MySort(self , arr: List[int]) -> List[int]:
def quicksort(arr,left,right):
if left>=right:
return 0
boundary = partion(arr,left,right)
quicksort(arr,boundary+1,right)
quicksort(arr, left, boundary-1)
return arr
def partion(arr,left,right):
boundary = -1+left
index = right
for i in range(left,right+1):
if arr[i]<=arr[index]:
boundary+=1
swap(arr,i,boundary)
return boundary
def swap(arr,left,right):
tmp = arr[left]
arr[left]=arr[right]
arr[right]=tmp
return quicksort(arr,0,len(arr)-1)