📜  python代码示例中的冒泡排序

📅  最后修改于: 2022-03-11 14:45:29.240000             🧑  作者: Mango

代码示例4
def bubbleSort(lis):
    length = len(lis)
    for i in range(length):
        for j in range(length - i):
            a = lis[j]
            if a != lis[-1]:
                b = lis[j + 1]
                if a > b:
                    lis[j] = b
                    lis[j + 1] = a
    return lis