Skip to content
Advertisement

Easy sort list 2D by column

I’m quiet new in Java data manipulation so I need some help if someone have a some good tips. Actually, I want just to find a easy way to sort a 2D list.

I create a list like this:

JavaScript

And then I want to have a result sorted by the second element like:

JavaScript

I tried something like Arrays.sort(A.toArray(), (int[]a, int[]b) -> a[0] - b[0]); but it doesn’t work.

Is there a simple solution to do that sort list?

Advertisement

Answer

Try this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement