冒泡排序:
li=[6,4,9,8,2,0,1,3,5,7] for i in range(len(li)-1): for j in range(i+1,len(li)): if li[i] > li[j]: tmp = li[j] li[j] = li[i] li[i] = tmp print li
结果:
[root@db01 xiao]# python paixu2.py [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]