python 冒泡排序

def mopsort(li):
for i in range(1,len(li)):
for j in range(len(li)-1):
if li[j] > li[j+1]:
temp = li[j]
li[j] = li[j+1]
li[j+1] = temp
return li

temp = [333,24,76,45,1,9,65]

tempsort = mopsort(temp)
print(tempsort)
posted @ 2018-04-05 21:33  wuxinyan  阅读(128)  评论(0编辑  收藏  举报