Python实现冒泡排序

# Python实现冒泡排序


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

L = [1, 45, 56, 0, 23, 13, 4, 14, 89, 23, 39, 34, 13, 40, 45, 23]
l = bubble(L)
print(l)

 

posted @ 2017-05-24 18:00  赵永杰博客  阅读(145)  评论(0编辑  收藏  举报