I've a question why can't I chain comparator in primitive array to sort by two values prioritizing one of them.
int[][] ints = {new int[]{7, 0}, new int[]{4, 4}, new int[]{7, 1}, new int[]{5, 0}, new int[]{6, 1}, new int[]{5, 2}};
Arrays.sort(ints , Comparator.comparing(x -> x[1])); // Is possible
Arrays.sort(ints , Comparator.comparing(x -> x[0])); // Is possible
Arrays.sort(ints , Comparator.comparing(x -> x[1]).thenComparing(x -> x[0])); // Is not possible
// The error is "java: array required, but java.lang.Object found"
Casting x (int[])x -> x[1] doesn't work either.
Can someone explain what's going under the hood. I would love to understand the mechanism.