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

Function insert_sort

code/all_sort.py:48–59  ·  view source on GitHub ↗
(arr1)

Source from the content-addressed store, hash-verified

46
47# 插入
48def insert_sort(arr1):
49 temp = [arr1[0]]
50 arr1 = arr1[1:]
51 while arr1:
52 for j in range(len(temp)):
53 if temp[j] > arr1[0]:
54 temp.insert(j, arr1[0])
55 break
56 else:
57 temp.insert(len(temp), arr1[0])
58 arr1.pop(0)
59 return temp
60
61def insertSort(relist):
62 len_ = len(relist)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected