Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 28d28b8

Browse files
Create insertion_sort.py
1 parent 52cba3f commit 28d28b8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sorting/insertion_sort.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
# author: bt3gl
4+
5+
def insertion_sort(lst):
6+
7+
for i in range(1, len(lst)):
8+
current_index = i
9+
10+
while current_index > 0 and lst[current_index - 1] > lst[current_index]:
11+
12+
lst[current_index], lst[current_index - 1] = lst[current_index - 1], lst[current_index]
13+
current_index -= 1

0 commit comments

Comments
 (0)