LintCode:整数排序
class Solution:
# @param {int[]} A an integer array
# @return nothing
def sortIntegers2(self, A):
# Write your code here
i = 0
j = len(A) - 1
self.quick_sort(A, i, j)
def quick_sort(self, A, low, high):
if low < high:
i = low
j = high
tmp = A[low]
while i < j:
while i < j and A[j] >= tmp:
j -= 1
A[i] = A[j]
while i < j and A[i] < tmp:
i += 1
A[j] = A[i]
A[i] = tmp
self.quick_sort(A, low, i-1)
self.quick_sort(A, i+1, high)