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

Commit 52cba3f

Browse files
Create bubble_sort.py
1 parent e1805c9 commit 52cba3f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sorting/bubble_sort.py

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

0 commit comments

Comments
 (0)