简单插入排序

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#-*- encoding= utf-8 -*-
def insertsort(list):
    if list != None:
        if len(list) == 1:
            pass
        else:
            for i in range(1,len(list)):#start with second item. 
                temp = list[i]
                for j in range(i):
                    if list[j]>list[i]:
                        for k in range(i,j,-1):#
                            list[k]= list[k-1]
                        list[j] = temp
                        
if __name__ == '__main__':                
    list1 = [3,2,7,5,8,9,6,54,1,42]
    insertsort(list1)
    print(list1)