__author__ = 'Alex Li'
def quick_sort(array,left,right):
'''
:param array:
:param left: 列表的第一个索引
:param right: 列表最后一个元素的索引
:return:
'''
if left >=right:
return
low = left
high = right
key = array[low]
while low < high:
while low < high and array[high] > key:
high -= 1
array[low] = array[high]
array[high] = key
while low < high and array[low] <= key :
low += 1
array[high] = array[low]
array[low] = key
quick_sort(array,left,low-1)
quick_sort(array,low+1, right)
if __name__ == '__main__':
array = [96,14,10,9,6,99,16,5,1,3,2,4,1,13,26,18,2,45,34,23,1,7,3,22,19,2]
print("before sort:", array)
quick_sort(array,0,len(array)-1)
print("-------final -------")
print(array)