From 61137618fcce80aeccd94098be3fab61be551d8e Mon Sep 17 00:00:00 2001 From: internetlandlord Date: Thu, 20 Oct 2022 22:55:41 +0000 Subject: Completed file i/o functionality in insertion sort script. --- insertion-sort.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/insertion-sort.py b/insertion-sort.py index 350c88b..dfb7900 100755 --- a/insertion-sort.py +++ b/insertion-sort.py @@ -1,10 +1,17 @@ #!/bin/python3 +# --------- Insertion sort + +# --------- Imported modules import inputoutput as io import csv import sys +# ingressing +target = sys.argv[1] +numdata = io.ingressCSV(target) + # insertion sort algorithm, as function def insertionSort(data): for i in range(1, len(data)): @@ -19,9 +26,15 @@ def insertionSort(data): # move key after element smaller than it data[j + 1] = key -testarr = [99,77,44,22,11,33] -print(testarr) -insertionSort(testarr) +#testarr = [99,77,44,22,11,33] +#print(testarr) +#insertionSort(testarr) #FIXME: no return argument needed! +#print(testarr) + +# sorting call +insertionSort(numdata) -print(testarr) +# wrapping up +print("Sorting done! Writing to file.") +io.egressCSV(numdata,target) -- cgit v1.2.3