1.冒泡排序
eg:
[1 3 5 7 9]
冒泡排序是前一个和后一个比
(1和3)(3和5)....
a=[4,7,9,2,5,1]
for i in range(len(a)):
for j in range(len(a)-i-1):
if a[j]<a[j+1]:
a[j],a[j+1]=a[j+1],a[j]
print(a)
2.快排
b=[4,7,9,2,5,1]
for i in range(len(b)):
for j in range(len(b)-1):
if b[i]<b[j]:
b[i],b[j]=b[j],b[i]
print(b)