冒泡排序的python实现

def sort(arr):
    count = len(arr) - 1
    for i in range(count):
        for j in range(count-i):
            if arr[j] < arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]
    return arr

l = [5, 2, 7, 8, 6, 1, 4, 9, 10, 1, 2, 3, 4]
print(sort(l))

本文名称:冒泡排序的python实现
当前地址:http://myzitong.com/article/pssegs.html