From 2a47aeda513e2d4b78fda648cb2782c98e0e3caf Mon Sep 17 00:00:00 2001 From: Sona Elizebeth Shaji <56604740+Sonaelizebeth@users.noreply.github.com> Date: Sun, 2 Oct 2022 18:46:14 +0530 Subject: [PATCH] Create Bubblesort.py --- python/Bubblesort.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 python/Bubblesort.py diff --git a/python/Bubblesort.py b/python/Bubblesort.py new file mode 100644 index 0000000..d422bef --- /dev/null +++ b/python/Bubblesort.py @@ -0,0 +1,21 @@ +def bubbleSort(array): + + for i in range(len(array)): + + + for j in range(0, len(array) - i - 1): + + + if array[j] > array[j + 1]: + + temp = array[j] + array[j] = array[j+1] + array[j+1] = temp + + +data = [-2, 45, 0, 11, -9] + +bubbleSort(data) + +print('Sorted Array in Ascending Order:') +print(data)