# 与选择排序相比,交换操作变成了移位操作(交换比移位耗时)所以时间较短
def insertMinSort(aList):
for i in range(1,len(aList)):
currentValue = aList[i]
position = i
while position > 0 and currentValue < aList[position - 1]:
aList[position] = aList[position - 1]
position -= 1
aList[position] = currentValue
alist = [54, 26, 93, 17, 77, 31, 44, 55, 20]
insertMinSort(alist)
print(alist)