def BubbleSort(nums):
for i in range(0,len(nums)-1):
for j in range(0,len(nums)-1-i):
if nums[j+1] < nums[j]:
nums[j],nums[j+1] = nums[j+1],nums[j]
return nums
def QuickSort(nums,lo,hi):
if hi - lo < 2:
return
mi = partition(nums,lo,hi-1)
QuickSort(nums,lo,mi)
QuickSort(nums,mi+1,hi)
def patition(nums,lo,hi):
nums[lo],nums[(lo + hi) // 2] = nums[(lo + hi) // 2],nums[lo]
p = nums[lo]
while(lo < hi):
while(lo<hi and p <= nums[hi]):
hi -= 1
nums[lo] = nums[hi]
while(lo < hi and nums[lo] <= p):
lo += 1
nums[hi] = nums[lo]
nums[lo] = p
return lo def quicksort(nums):
QuickSort(nums,0,len(nums))