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
i=low
j=high
temp=a[low]
while i
while a[j]>temp and i
j-=1
if i
a[i]=a[j]
i+=1
while a[i]
i+=1
if i
a[j]=a[i]
j-=1
a[i]=temp
quickSort(a,low,i-1)
quickSort(a,i+1,high)
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
i=low
j=high
temp=a[low]
while i
while a[j]>temp and i
j-=1
if i
a[i]=a[j]
i+=1
while a[i]
i+=1
if i
a[j]=a[i]
j-=1
a[i]=temp
quickSort(a,low,i-1)
quickSort(a,i+1,high)