I have one List<List> I want to sort it according to column . I used the following code.
// data is List<List<String>>
data.sort(Comparator.comparing(e-> e.get(col)));
Its working and sorting according column specified. But If I used reversed()
or thenComparing()
method, It says
error: cannot find symbol
data.sort(Comparator.comparing(e-> e.get(col)).reversed() );
^
symbol: method get(int)
location: variable e of type Object
Also with the thenComparing method,
error: cannot find symbol
data.sort(Comparator.comparing(e-> e.get(col)).thenComparing(e->e.get(col2)) );
^
symbol: method get(int)
location: variable e of type Object
error: cannot find symbol
data.sort(Comparator.comparing(e-> e.get(col)).thenComparing(e->e.get(col2)) );
^
symbol: method get(int)
location: variable e of type Object
2 errors
I'm not getting anything from the error messages. Fyi, Im using OpenJDK 11 for this.
> with some data then I'm sorting it. then just printing it to the console.
– Aug 07 '20 at 09:53