【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 @   炼狱腾蛇  阅读(120)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示