From 6f36536660fbfa8117381320d6de0c151d01e3e4 Mon Sep 17 00:00:00 2001 From: Lucas Pierre de Alencar Date: Fri, 11 Oct 2019 13:39:24 -0300 Subject: [PATCH] Create bubble_sort.py --- bubble_sort.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 bubble_sort.py diff --git a/bubble_sort.py b/bubble_sort.py new file mode 100644 index 0000000..4112d17 --- /dev/null +++ b/bubble_sort.py @@ -0,0 +1,8 @@ +def bubble_sort(lista): + fim = len(lista) + for i in range(fim-1, 0, -1): + for j in range(i): + if lista[j] > lista[j+1]: + lista[j], lista[j+1] = lista[j+1], lista[j] + print(lista) + return lista