From 7fef7e0d0948f24460f81ad590c1d2e90ac6490b Mon Sep 17 00:00:00 2001 From: internetlandlord Date: Fri, 21 Oct 2022 18:15:42 +0000 Subject: added bubble sort algorithm --- bubble-sort.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 bubble-sort.py diff --git a/bubble-sort.py b/bubble-sort.py new file mode 100755 index 0000000..431a6f2 --- /dev/null +++ b/bubble-sort.py @@ -0,0 +1,27 @@ +#!/bin/python3 + +# ---------- title + + + +# ---------- Imported modules +import inputoutput as io +import csv +import sys + + +# ---------- Main +target = sys.argv[1] + +# ingress of data +numdata = io.ingressCSV(target) + +# bubble sort operation +for i in range(len(numdata)): + for j in range(0,len(numdata)-i-1): + if numdata[j] > numdata[j+1]: + numdata[j], numdata[j+1] = numdata[j+1], numdata[j] + +# finishing up +print("writing to file") +io.egressCSV(numdata,target) -- cgit v1.2.3