Python冒泡排序

def BubbleSort(list):
    long = len(list)
    for i in range(0,long):
        for j in range(i,long):
            if list[i] < list[j]:
                list [i],list[j] = list[j],list[i]
            else:
                pass
    return list

list = [23, 12, 1, 56, 34, 78, 1, 55, 4, 2, 66]
print(BubbleSort(list))

posted @ 2020-04-29 14:46  Treasure丶丶  阅读(111)  评论(0编辑  收藏  举报