i created a 2d string array (called data) which contains on the first position an integer (as a string) and on the second position a link to a file.
Examples:
["3", "Test3.pdf"]; ["1", "Test1.pdf"]; ["2", "Test2.pdf"]; ["10", "Test10.pdf"]
So now I need to sort the array ascending for the integer. So the result of the sorting should be an sorted array like:
["1", "Test1.pdf"]; ["2", "Test2.pdf"];["3", "Test3.pdf"];["10", "Test10.pdf"]
I found some sample code for this:
Arrays.sort(data, new Comparator<String[]>() {
@Override
public int compare(final String[] entry1, final String[] entry2) {
final String time1 = entry1[0];
final String time2 = entry2[0];
return time1.compareTo(time2);
}
});
but the problem is, that in this case it compares it with string logic, so the result would be-> 1,10,2,3. So I cannot archive the result with this. Do you know what can I do? You only can have an 2d array of one type? not mix of string and integer?
intandStringparts would almost certainly be better, not just here but throughout your code.intin thecomparemethod.TreeMap<Integer,String>