I have a 2d array containing first name, last name, and a third irrelevant piece of data on each row. I need to alphabetize each row based on last name. How can I accomplish this?
I've tried using java.util.Arrays.sort(array[0]); but I can only get it to sort one row or one column. I need to keep the first name and last name together and sort by last name.
so say i have this array
String array [][]=new String[3][2];
array[0][0]="Kyle";
array[0][1]="Johnson";
array[1][0]="Drew";
array[1][1]="Anderson";
array[2][0]="Jacob";
array[2][1]="Peterson";
which is build like this
Kyle | Johnson
Drew | Anderson
Jacob| Peterson
and i need it to end up like this
Drew | Anderson
Kyle | Johnson
Jacob| Peterson