Consider that Collections.reverseOrder() has type Comparator and you are
comparing String objects, so for that you sort for column 1 that's the
beginnig of the row. You shoud use a custom Comparator that compare
column 6. For example;
Comparator comparator = new Comparator<String>() {
public int compare(String o1, String o2) {
int comp = o2.compareTo(o1);
return comp;
}
}
for ascending order reverse the comparison to o1.compareTo(o2); so your
statement would be Arrays.sort(fileArray, comparator); tha's not
different from Collections.reverseOrder().
Now the problem is parsing strings to get 6th column from both o1 and o2
inside the method compare.
One trivial way could be compare the substring between 5th and 6th
comma-separator, e.g.:
public int compare(String o1, String o2) {
String[] a1 = o1.split(","), a2 = o2.split(",");
int comp = a2[5].compareTo(a1[5);
return comp;
}
but it's a weak way, as some text column can have the comma-separator
part of the text. Doing a stronger job is like reinventing the wheel:
there are plenty of java libraries, most of them open-source, that
extract columns from each row.