implements insertion sort in c and pytyhon

This commit is contained in:
2023-08-07 23:25:17 -07:00
parent 09e18f9ac9
commit 82d3973ade
3 changed files with 56 additions and 14 deletions

13
python/insertion-sort.py Normal file
View File

@@ -0,0 +1,13 @@
def insertion_sort(array):
for index in range(1, len(array)):
temp_value = array[index]
position = index - 1
while position >= 0:
if array[position] > temp_value:
array[position + 1] = array[position]
else:
break
array[position + 1] = temp_value
return array