排序之插入

def Insert(lis:list):

    length = len(lis)
    for i in range(1,length):

        while lis[i] < lis[i-1]:
            lis[i], lis[i-1] = lis[i-1], lis[i]
            i -= 1
            if not i-1 >= 0:
                break
    return lis

插入:要防止索引越界

原文地址:https://www.cnblogs.com/zengmu/p/12824914.html