summaryrefslogtreecommitdiff
path: root/selection-sort.py
diff options
context:
space:
mode:
Diffstat (limited to 'selection-sort.py')
-rwxr-xr-xselection-sort.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/selection-sort.py b/selection-sort.py
new file mode 100755
index 0000000..c41c86e
--- /dev/null
+++ b/selection-sort.py
@@ -0,0 +1,32 @@
+#!/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)
+
+# selection sort algorithm
+for i in range(len(numdata)):
+ mindex = i
+
+ for j in range(i+1, len(numdata)):
+ if numdata[mindex] > numdata[j]:
+ mindex = j
+
+ # updating values - trying without simulatenous assignment
+ numdata[i], numdata[mindex] = numdata[mindex], numdata[i]
+
+# finishing up
+print("writing to file")
+io.egressCSV(numdata,target)