diff options
author | internetlandlord <f.fredhenry@gmail.com> | 2022-10-21 18:15:42 +0000 |
---|---|---|
committer | internetlandlord <f.fredhenry@gmail.com> | 2022-10-21 18:15:42 +0000 |
commit | 7fef7e0d0948f24460f81ad590c1d2e90ac6490b (patch) | |
tree | 9be714f2712258b9d948eedd3cddffd82d51b6d8 | |
parent | ed5780a5f91b624fc79c6b1d2f92b6002f658a2c (diff) |
added bubble sort algorithm
-rwxr-xr-x | bubble-sort.py | 27 |
1 files changed, 27 insertions, 0 deletions
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) |