From d88e248f33eaf413a7587616e1a4b33388a482c2 Mon Sep 17 00:00:00 2001 From: Siddhant Chourasia Date: Sat, 31 Oct 2020 17:47:17 +0530 Subject: [PATCH] Create BubbleSort.py --- 10_SortNumbers/BubbleSort.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 10_SortNumbers/BubbleSort.py diff --git a/10_SortNumbers/BubbleSort.py b/10_SortNumbers/BubbleSort.py new file mode 100644 index 0000000..868d0f8 --- /dev/null +++ b/10_SortNumbers/BubbleSort.py @@ -0,0 +1,11 @@ +def bubbleSort(arr): + n = len(arr) + for i in range(n-1): + for j in range(0, n-i-1): + if arr[j] > arr[j+1] : + arr[j], arr[j+1] = arr[j+1], arr[j] +arr = [64, 34, 25, 12, 22, 11, 90] +bubbleSort(arr) +print ("Sorted array is:") +for i in range(len(arr)): + print ("%d" %arr[i]),