From a5351cec74312ebdf1cfb683defbde52eb662ab1 Mon Sep 17 00:00:00 2001 From: "mr.secret" <26296824+mister-secret@users.noreply.github.com> Date: Thu, 31 Oct 2019 12:33:49 +0900 Subject: [PATCH] Create bubble_sort.py --- sorting-algorithms/bubble_sort.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 sorting-algorithms/bubble_sort.py diff --git a/sorting-algorithms/bubble_sort.py b/sorting-algorithms/bubble_sort.py new file mode 100644 index 0000000..e082a40 --- /dev/null +++ b/sorting-algorithms/bubble_sort.py @@ -0,0 +1,13 @@ +a = [16, 19, 11, 15, 10, 12, 14] + +for j in range(len(a)): + swapped = False + i = 0 + while ia[i+1]: + a[i],a[i+1] = a[i+1],a[i] + swapped = True + i = i+1 + if swapped == False: + break +print (a)