Create bubble_sort.py

This commit is contained in:
marina 2023-08-02 20:53:18 -07:00 committed by GitHub
parent e1805c9fb5
commit 52cba3f861
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

16
sorting/bubble_sort.py Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author: bt3gl
def bubble_sort(list)
has_swapped = True
while has_swapped:
has_swapped = False
for i in range(len(lst) - 1):
if lst[i] > lst[i + 1]:
lst[i], lst[i + 1] = lst[i + 1], lst[i]
has_swapped = True