From 204db0b547b57882afc3f9eb2e37eb47fe2e3727 Mon Sep 17 00:00:00 2001 From: Huzefa Taj <47708830+huzefaTaj@users.noreply.github.com> Date: Mon, 10 Oct 2022 22:41:08 +0530 Subject: [PATCH] Create BubbleSort.py --- BubbleSort.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 BubbleSort.py diff --git a/BubbleSort.py b/BubbleSort.py new file mode 100644 index 0000000..f6d9853 --- /dev/null +++ b/BubbleSort.py @@ -0,0 +1,14 @@ +def sort(nums): + + for i in range(len(nums)-1,0,-1): + for j in range(i): + if nums[j]>nums[j+1]: + temp = nums[j] + nums[j] = nums[j+1] + nums[j+1] = temp + + +nums = [5, 3, 8, 6, 7, 2] +sort(nums) + +print(nums)