Okay, so right now I have a parseCSV function that returns a table to me in 2D format like so:
List<string[]> data = parseCSVFle(file);
Now, I'd like the rows in 'data' to be arranged in a particular order. This order is determined by the first column in temp (i.e. first element of the string array). The order is maintained in a string array elsewhere.
String[] dogs = {"rottweiler", "germanshepherd", "dalmatian"};
How do I rearrange 'data' to reflect the order in 'dogs'?
Additional constraints include
- The string in 'dogs' may be a substring of the string in 'data'. In this case, the string from 'dogs' is displayed.
- The string in 'dogs' may not be present in 'data' at all. In this case, the string from 'dogs' is added to the 2D table but with blanks in the other columns.
Example data
data_initial
dalmatian 45 52 rottweiler 58
data_final
rottweiler 58 - germanshepherd - - dalmatian 45 52
Thanks for looking, all.