Valizada's blog

Java - sort two dimensional array with Stream API

Use stream api to quickly sort a 2D array in Java.

var people = new int[10][10];

Arrays.sort(people, (x, y) -> {
            return x[0] == y[0]
                ? x[1] - y[1]
                : y[0] - x[0];
        });