插入排序的python实现

def sort(arr):
    count = len(arr)

    for i in range(1, count):
        j = i
        while j > 0 and arr[j-1] < arr[j]:
            arr[j-1], arr[j] = arr[j], arr[j-1]
            j -= 1
    return arr

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

网页名称:插入排序的python实现
文章路径:http://www.gydahua.com/article/gpchoh.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流