-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertion_sort.py
More file actions
28 lines (26 loc) · 821 Bytes
/
insertion_sort.py
File metadata and controls
28 lines (26 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
array = [1, 2, 3, 5, 4]
def insertion_sort(array):
temp0 = 0
temp_array = []
insertion = False
for i in range(len(array)-1):
insertion = False
if array[i] < array[i+1]:
pass
else:
temp0 = array[i]
array[i] = array[i+1]
print(temp0)
for j in range(len(array)-1):
print(insertion)
if insertion:
print("if insertion")
temp_array.append(array[j])
elif temp0 < array[j] or j == (len(array)-1):
temp_array.append(temp0)
insertion = True
print(f"array: {array} temp_array: {temp_array}")
array = temp_array
temp_array = []
print(array)
insertion_sort(array)