插入排序法

def sort1(x):
    l=len(x)
    if l==1 or l==0:
        return x
    else:
        for j in range(1,l):
           key=x[j]
           i=j-1
          
           while i>=0 and x[i]>key:
               x[i+1]=x[i]
               i=i-1
           x[i+1]=key
        return x
           

你可能感兴趣的:(插入排序法)