I have a for-loop that prints the data. In the first position is a letter and in the second is number. Like this:
H 8
T 3
A 9
F 4
How can I sort this data in lexicographic (alphabetical) (key is a letter) order? Output must be:
A 9
F 4
H 8
T 3
Should I put the data into the list and use Collections.sort(list);
? In this case the numbers are not in the necessary position.
P.S Actually this is a small part of a homework, but I do not know how to solve this.