how to sort a 2d array in java according to a row code example Example: How to sort 2d array in java using stream api Arrays.sort(myArr, (a, b) -> a[0] - b[0]);