冒泡排序原理:每次遍历都去依次比较相邻2个数字的大小,小的数字放在前面
遍历的次数为数组的长度
每次遍历需要进行比较的次数为 数组的长度-遍历的次数
def busort(numbs):
for i in range(len(numbs)):
for j in range(1,len(numbs)-i):
if numbs[j-1] > numbs[j]:
numbs[j-1],numbs[j] = numbs[j],numbs[j-1]
return numbs
numbs = [3,2,4,4,5,6,1,7,9,22,11,44,33,77,55,66,66,88]
print busort(numbs)