冒泡排序

def bubbleSort(arr,length):
for j in range(length):
for i in range(length-1):
if arr[i] > arr[i+1]:
arr[i],arr[i+1] = arr[i+1],arr[i]
return arr

if __name__ == "__main__":
li=[1, 3, 10, 9, 21, 35, 4, 6]
s=len(li)
print(bubbleSort(li,s))
posted @ 2019-07-19 09:04  by2018  阅读(180)  评论(0编辑  收藏  举报