I need to sort a csv file by the third column, but I'm stuck and I can't find a solution.
Code:
import java.util.*;
import java.io.*;
public class SalesStatistics{
public static void main(String[] args){
String filePath = "Filepath";
ArrayList<String> csvValues = new ArrayList<String>();
try{
BufferedReader br = new BufferedReader( new FileReader(filePath));
String strLine = "";
StringTokenizer str = null;
while( (strLine = br.readLine()) != null){
str = new StringTokenizer(strLine, ",");
while(str.hasMoreTokens())
csvValues.add(str.nextToken());
}
}catch(Exception e){
System.out.println("Exception while reading csv file: " + e);
}
}
}
My csv file is something like this one:
1001,Name1,9
1005,Name2,20
1007,Name3,14
And I need it to be:
1001,Name1,9
1007,Name3,14
1005,Name2,20