From 0e2b2f1d24cc068851dc6688c9c26c551448b562 Mon Sep 17 00:00:00 2001 From: "W. Bender" <76257056+h2o-commits@users.noreply.github.com> Date: Tue, 14 Jan 2025 22:35:48 +0100 Subject: [PATCH] Add Bubble_Sort --- Bubble_Sort.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Bubble_Sort.py diff --git a/Bubble_Sort.py b/Bubble_Sort.py new file mode 100644 index 0000000..c1a6c17 --- /dev/null +++ b/Bubble_Sort.py @@ -0,0 +1,12 @@ +def bubble_sort(input_list): + for idx in range(0,len(input_list)): + min_idx = idx + for j in range( 1, len(input_list)-idx): + if input_list[j-1] > input_list[j]: + input_list[j-1], input_list[j] = input_list[j], input_list[j-1]; + +# add any list of number here +l = [5,2,4,6,1,3]; + +bubble_sort(l); +print(l);