I have an ArrayList of ArrayList of Floats and I'm looking to sort the array by one of the values of the inner ArrayList.
For example
[1.2,2.0,3.5]
[1.3,3.3,5.6]
[5.7,5.3,1.4]
I want to sort this by the last value so that the output will be as the following (lowest to highest)
[5.7,5.3,1.4]
[1.2,2.0,3.5]
[1.3,3.3,5.6]
The values themselves do not change just the order so that the ArrayList goes from lowest to highest based on the 3rd value in the inner ArrayList.
I tried list.sort(Comparator.comparing(l -> l.get(2)));
as suggested below but I am getting an error: The method comparing(( l) -> {}) is undefined for the type Comparator
>`, so it would also work for `ArrayList>`.
– Jorn Vernee Aug 28 '16 at 21:15