Abstract Array // Sort an array which has elements that are array of size 2 // Sort from the highest first element of sub-array, if same then sort from the lowest second element of sub-array Arrays.sort(people, (a,b) -> { if (a[0] == b[0]) return a[1] - b[1]; return b[0]-a[0]; }); // Sort array of elements that are long type Arrays.sort(longArray, (a, b) -> { if (a[0] == b[0]) return Long.compare(a[1], b[1]); return Long.compare(a[0], b[0]); }); // Use the built-in comparator will not lead to overflow issue Arrays.sort(points, (a, b) -> Integer.compare(a[0], b[0])); Dyanmic List Collections.sort(inputList, Comparator.comparingInt(a -> a[0] + a[1]));