python实现插入排序

import random

def insert_sort(li): for i in range(1, len(li)): j = i - 1 tmp = li[i] while j >= 0 and li[j] > tmp: li[j+1] = li[j] j -= 1 li[j+1] = tmp li = list(range(10000)) random.shuffle(li) insert_sort(li)

 

posted @ 2018-02-03 13:14  小学弟-  阅读(98)  评论(0编辑  收藏  举报