Hello!
I have two Hashmaps:

POINTS (String/int)
Player A: 0
Player B: 3
Player C: 5
Player D: 2
Player E: 5
Player F: 3
TIME (sec) (String/int)
Player A: 0
Player B: 15
Player C: 9
Player D: 8
Player E: 12
Player F: 15

The progrom should first order by the points, if two players have the same, the player with the longest time wins. If also that is identical, both players share a spot.
In that example:

1. Player E
2. Player C
3. Player F and Player B
4. Player D
5. Player A

Both hashmaps are already implemented (Key = Playername, Value = Points/Time). But how can I order them? Do I need to implement a comparator (how?)?
Thanks a lot

Recommended Answers

All 2 Replies

What hashmap methods have you tried?

Is it a requirement that you use two hashmaps?
Could you, for example, create class Result with instance variables name, points, time?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.