I have an Arraylist letters which contains letter f r t d, and also two more Arraylists one of which stores the row poistion of a letter and the other stores the col position for a letter.
But after sorting the Arraylist letters alphabetically (Collections.sort(letters)) how can I also sort the row and col values for each letter correspondingly? For example, if the letter d has row = 4and col ==3 then after sorting d would be in the first place and takes the row and ``col values of f. How can I do that if letters get their row and col values.
Given:
ArrayList<Character> letters;
ArrayList<Integer> rows;
ArrayList<Integer> cols;
Snippet:
Collections.sort(letters);
for(int i = 0; i < letters.size(); i++)
{
System.out.println(letters.get(i).getChar() + rows.get(i) + col.get(i)
}