Below is my list, which will always be in shape bXXXX-
List<String> data = Arrays.asList("b5", "b10", "b2", "b1", "b40");
System.out.println(data);
There datawill always be lines in the form in my listbXXXX
Now I need to sort my lists above in descending order and extract the largest row from it.
So in the example above it will be b40. So below is a comparator that sorts everything in ascending order -
static final Comparator<String> aStringComparator = new Comparator<String>() {
public int compare(String s1, String s2) {
int numfromS1 = Integer.valueOf(s1.subSequence(1, s1.length()).toString());
int numfromS2 = Integer.valueOf(s2.subSequence(1, s2.length()).toString());
return numfromS1 - numfromS2;
}
};
And I can't figure out how to do this, to sort it in descending order, so that I can extract the first index from the list, which will be the largest row number?
user2467545
source
share