def partition(numList,p,q): x = numList[p]; #pivot i = p; for j in range(p+1,q): if numList[j] <= x: i = i + 1; tmp = numList[i]; numList[i] = numList[j]; numList[j] = tmp; tmp = numList[p]; numList[p] = numList[i]; numList[i] = tmp; return i;
def quickSort(numList,p,q): global alist; alist = numList; if p < q: r = partition(numList,p,q); quickSort(numList,p,r); quickSort(numList,r+1,q); return alist;