1.选择
>>> def choice(l):
a=len(l)
for i in range(a):
maxx=i
for j in range(i+1,a):
if l[j]>l[maxx]:
maxx=j
if maxx!=i:
l[i],l[maxx]=l[maxx],l[i]
print l
2.冒泡排序
>>> def bubble(l):
for i in range(len(l)):
for j in range(len(l)-i-1):
if l[j]>l[j+1]:
l[j],l[j+1]=l[j+1],l[j]
print l
3.快排
def quickSort(a,low,high):
if low<high:
i=low
j=high
temp=a[low]
while i<j:
while a[j]>temp and i<j:
j-=1
if i<j:
a[i]=a[j]
i+=1
while a[i]<temp and i<j:
i+=1
if i<j:
a[j]=a[i]
j-=1
a[i]=temp
quickSort(a,low,i-1)
quickSort(a,i+1,high)