MCPcopy Create free account
hub / github.com/DasyDong/developer-roadmap / insertSort

Function insertSort

code/all_sort.py:61–69  ·  view source on GitHub ↗
(relist)

Source from the content-addressed store, hash-verified

59 return temp
60
61def insertSort(relist):
62 len_ = len(relist)
63 for i in range(1,len_):
64 for j in range(i):
65 if relist[i] < relist[j]:
66 relist.insert(j,relist[i]) # 首先碰到第一个比自己大的数字,赶紧刹车,停在那,所以选择insert
67 relist.pop(i+1) # 因为前面的insert操作,所以后面位数+1,这个位置的数已经insert到前面去了,所以pop弹出
68 break
69 return relist
70
71# 冒泡
72def bubble_sort(arr1):

Callers 1

shell_sortFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected