插入排序
import random
def insert_sort(list):
for i in range(1, len(list)):
tmp = list[i]
j = i - 1
while j >= 0 and list[j] > tmp:
list[j + 1] = list[j]
j -= 1
list[j + 1] = tmp
li = [random.randint(10000) for i in range(100)]
print(li)
insert_sort(li)
视频源地址:https://www.bilibili.com/video/BV1XL411g7qF?p=15