3 ms·
Remember to add two spaces to get the correct formating: def insertionSort(array): for i in range(1, len(array)): temp = array[i] tempPos = i
by gus_massa 1y ago
Remember to add two spaces to get the correct formating:
def insertionSort(array):
for i in range(1, len(array)):
temp = array[i]
tempPos = i-1
flag = False
while flag == False and tempPos > -1:
print(array)
if temp < array[tempPos]:
array[i] = array[tempPos]
array[i-1] = temp
tempPos = tempPos - 1
i = i - 1
else:
flag = True