We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eb4afa4 commit 0438945Copy full SHA for 0438945
basic/sorting/InsertionSort/InsertionSort.py
@@ -0,0 +1,10 @@
1
+def insertion_sort(array):
2
+ for i in range(len(array)):
3
+ cur_index = i
4
+ while array[cur_index - 1] > array[cur_index] and cur_index - 1 >= 0:
5
+ array[cur_index], array[cur_index - 1] = array[cur_index - 1], array[cur_index]
6
+ cur_index -= 1
7
+ return array
8
+
9
+array = [10, 17, 50, 7, 30, 24, 27, 45, 15, 5, 36, 21]
10
+print(insertion_sort(array))
0 commit comments