I have two arrays, one is a 2 dimensional array, the other is a single dimensional array. I want to sort the second array in relation with the first array
Example
Input
Long [][] timeArray = {(1,2),(6,8),(3,5)};
String [] nameList = {George, Bill, Harry};
Output
timeArray = {(1,2),(3,5),(6,8)} //Array sorted in ascending order
nameList = {George, Harry, Bill} //Array sorted in relation to timeArray
I am able to sort the 2D array using
Arrays.sort(timeArray, Comparator.comparingLong(a -> a[0]));
but I am not able to figure a way to sort them in relation with each other without using over-complicated code.