【Python】【Algorithm】排序

冒泡排序

 

dic = [12, 45, 22, 6551, 74, 155, 6522, 1, 386, 15, 369, 15, 128, 123, ]

for j in range(1, len(dic)):
    for i in range(len(dic)-j):
        if dic[i] > dic[i+1]:
            temp = dic[i]
            dic[i] = dic[i+1]
            dic[i+1] = temp

print(dic)

 

posted @ 2017-09-28 11:18  炼狱腾蛇  阅读(119)  评论(0编辑  收藏  举报