From 4f57198ce0469f82fa5f18bbf004d59ef1407deb Mon Sep 17 00:00:00 2001 From: Mateusz779 <73058906+Mateusz779@users.noreply.github.com> Date: Wed, 15 Dec 2021 19:32:55 +0100 Subject: [PATCH] Add files via upload --- bubble_sort_py/bubble_sort_py.py | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 bubble_sort_py/bubble_sort_py.py diff --git a/bubble_sort_py/bubble_sort_py.py b/bubble_sort_py/bubble_sort_py.py new file mode 100644 index 0000000..69ca074 --- /dev/null +++ b/bubble_sort_py/bubble_sort_py.py @@ -0,0 +1,43 @@ + + +def sort_func(sort=[],repeat=False): + + global size_array + size_array = 0 + + t = True + j = 0 + le=len(sort)-1 + + while (t): + for i in range(0,le-1): + if sort[i] > sort[i + 1]: + tmp1 = sort[i]; + sort[i] = sort[i + 1]; + sort[i + 1] = tmp1; + j = 0; + elif sort[i] == sort[i + 1] and repeat==False: + del sort[i] + + size_array=size_array-1 + le=le-1 + j = 0; + else: + if (j == le): + t = False + else: + j=j+1; + return sort + + + +def main(): + + temp=[2,7,2,1,3,100,3,32,342,2,44,23] + sorted=sort_func(temp,False) + for i in sorted: + print(i) + +if __name__ == '__main__': + main() +