Top leader board

Discussion in 'Plugin Development' started by thepaperboy99, Aug 13, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    thepaperboy99

    Hello Bukkit, I was wondering if anyone knows how I can sort Hashmaps to get the top kills of players. For example, I have a hashmap with <String,Integer>, and at the end of the game, I want to sort everyone and get the top player to announce he won. I tried to google this, but didn't really help me. If anyone has suggestions, please tell me. I would greatly appreciate it. Thanks :)
     
  2. Offline

    Polaris29

    Put all the values into a list then use Collections.sort(list) which will sort an Integer list in ascending order. Then get the last value, which will be the highest number, of the list and get the first key with that value from your map.
     
  3. Offline

    thepaperboy99

    Thanks! Works perfect!
     
Thread Status:
Not open for further replies.

Share This Page