插入排序的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.csruizhi.cn/article/gpchoh.html

其他资讯

Copyright © 2007-2024 成都优众联杰科技有限公司 All Rights Reserved 蜀ICP备2024116266号
友情链接: 网站设计制作报价 成都定制网站建设 定制网站设计 定制网站设计 成都网站建设推广 泸州网站建设 重庆企业网站建设 温江网站设计 营销型网站建设 自适应网站建设 网站建设公司 外贸网站建设 商城网站建设 成都定制网站建设 成都网站建设 成都网站建设 手机网站建设套餐 移动手机网站制作 H5网站制作 成都网站制作 成都网站建设 网站设计