From 52cba3f861eae6e03dfc1467dd31801b9337e43e Mon Sep 17 00:00:00 2001 From: marina <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Wed, 2 Aug 2023 20:53:18 -0700 Subject: [PATCH] Create bubble_sort.py --- sorting/bubble_sort.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sorting/bubble_sort.py diff --git a/sorting/bubble_sort.py b/sorting/bubble_sort.py new file mode 100644 index 0000000..4a27baf --- /dev/null +++ b/sorting/bubble_sort.py @@ -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