CS 112 - Introduction to Computer Science II
Individual Exercise #7

Due: At the beginning of class 41.

NOTE: This work is to be done independently. 

Your assignment submission will consist of a single file: SortCSV.java 

SortCSV - Sorting a Comma-Separated Value (CSV) file

In this exercise, you will read from standard input a restricted form of the standard CSV format, parse it an ArrayList consisting of one array of Integer/Double/String objects per line, sort these array "records" according to a given 0-based column index, and write the resulting sorted records to the standard output using the same CSV format.

Implement methods according to this javadoc specification.

Tips:

Test input and output:

Input (file test.csv):

0.3004519597811317,0.9268288847188403,-367008613,-2064516610,"edde a","d bec bc"
0.18080469607648608,0.19773271689988925,1055319097,-284027527,"c ec ","eedaa"
0.09316631106113582,0.9941370906863541,-2101883725,164642859,"dadab","d aadb"
0.5924837178209116,0.5805745899599044,-745481776,-876624537,"abcedd ","ba ac"
0.46591053580255914,0.846345567675901,488646779,-671791003,"acdaa"," e ceabd"

Output (file sorted.csv) of terminal command "java SortCSV < test.csv > sorted.csv":

0.09316631106113582,0.9941370906863541,-2101883725,164642859,"dadab","d aadb"
0.18080469607648608,0.19773271689988925,1055319097,-284027527,"c ec ","eedaa"
0.3004519597811317,0.9268288847188403,-367008613,-2064516610,"edde a","d bec bc"
0.46591053580255914,0.846345567675901,488646779,-671791003,"acdaa"," e ceabd"
0.5924837178209116,0.5805745899599044,-745481776,-876624537,"abcedd ","ba ac"

Output (file sorted.csv) of terminal command "java SortCSV  0 < test.csv > sorted.csv":

0.09316631106113582,0.9941370906863541,-2101883725,164642859,"dadab","d aadb"
0.18080469607648608,0.19773271689988925,1055319097,-284027527,"c ec ","eedaa"
0.3004519597811317,0.9268288847188403,-367008613,-2064516610,"edde a","d bec bc"
0.46591053580255914,0.846345567675901,488646779,-671791003,"acdaa"," e ceabd"
0.5924837178209116,0.5805745899599044,-745481776,-876624537,"abcedd ","ba ac"

Output (file sorted.csv) of terminal command "java SortCSV  2 < test.csv > sorted.csv":

0.09316631106113582,0.9941370906863541,-2101883725,164642859,"dadab","d aadb"
0.5924837178209116,0.5805745899599044,-745481776,-876624537,"abcedd ","ba ac"
0.3004519597811317,0.9268288847188403,-367008613,-2064516610,"edde a","d bec bc"
0.46591053580255914,0.846345567675901,488646779,-671791003,"acdaa"," e ceabd"
0.18080469607648608,0.19773271689988925,1055319097,-284027527,"c ec ","eedaa"

Output (file sorted.csv) of terminal command "java SortCSV  5 < test.csv > sorted.csv":

0.46591053580255914,0.846345567675901,488646779,-671791003,"acdaa"," e ceabd"
0.5924837178209116,0.5805745899599044,-745481776,-876624537,"abcedd ","ba ac"
0.09316631106113582,0.9941370906863541,-2101883725,164642859,"dadab","d aadb"
0.3004519597811317,0.9268288847188403,-367008613,-2064516610,"edde a","d bec bc"
0.18080469607648608,0.19773271689988925,1055319097,-284027527,"c ec ","eedaa"

Todd W. Neller