I'm using a HashMap<String,Integer>
for a sort of timed Voting system. Where the string is the name of the object, and the integer is the amount of votes that object has. What I'm trying to do, is sort the integer descending, and if their is a tie, I'd like to choose whichever did not previously win the vote (if either of them did)
I tried using a TreeMap
, but it doesn't seem to do what I want, since it sorts based on the value of the key, while I need the value sorted. Also doesn't work as some times two objects could both have the same number of votes.