首页 > 代码库 > python插入排序实现:

python插入排序实现:

插入排序实现:

def insert_sort(arr):    i =1    while i <=len(arr)-1:        key = arr[i];        j =i -1        i +=1        while j >=0 and arr[j]>key:            arr[j+1] = arr[j]            j -=1        arr[j+1] = key    return arr     a = insert_sort([1,2,4,3])print(a)
 

 

python插入排序实现: