def q(start , end , a):
    if start>= end :
        return
    else :
        mid = (start+end)/2
        i = start+1
        j = end
        key =a[start]
        while i<j:
            while i<=end and a[i]<key:
               i+=1
            while j>=start and a[j]>key:
               j-=1
            if i < j:
                tmp = a[i]
                a[i]=a[j]
                a[j]=tmp
        if a[start] > a[j]:
            tmp = a[start]
            a[start] = a[j]
            a[j] = tmp
        q(start,j-1,a)
        q(j+1,end ,a)
l = input('please input the length of array')
n = []
for x in range(l):
    n.append(input())
q(0,l-1, n)
print n啊,写完了。原文地址:http://blog.csdn.net/u011700281/article/details/43795929