I am making a java project which records football games and displays the league table. When a game is added to the league between two teams, I need a way of storing the teams position in the league based on the number of points that the Team have.
To do this is am thinking of using a HashMap< Integer, Team > where the Integer is storing the Teams position in the league based on the number of points that a team has. Whenever a new game is added I need a way of ordering this list so that it is sorted where the Teams with the greatest number of points are closer to the number one position.
For example, if there are three teams
Team A with 8 points, Team B with 5 points, Team C with 4 point
I would like the Map to be ordered as such
1 : A, 2 : B, 3 : C
My question are:
1) Do you think I should be using a HashMap or TreeMap for this instance?
2) How would I implement the code to sort the league by points aquired?