From d5fcfb464438a6a22a9dab9207ce8cffd54f2569 Mon Sep 17 00:00:00 2001 From: Swapnil Sinha Date: Sun, 14 Oct 2018 16:59:42 +0530 Subject: [PATCH] Added a Python Program to implement Bubble Sort --- bubble.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 bubble.py diff --git a/bubble.py b/bubble.py new file mode 100644 index 0000000..b0cbd36 --- /dev/null +++ b/bubble.py @@ -0,0 +1,11 @@ +def bubbleSort(alist): + for passnum in range(len(alist)-1,0,-1): + for i in range(passnum): + if alist[i]>alist[i+1]: + temp = alist[i] + alist[i] = alist[i+1] + alist[i+1] = temp + +alist = [54,26,93,17,77,31,44,55,20] +bubbleSort(alist) +print(alist)