How can I find the rank of a player based on kills if my config looked like this: Code: Player1: deaths: 10 kills: 2 Player2: deaths: 3 kills: 4 Player3: deaths: 7 kills: 12 Example: Since player3 has 12 kills they would be rank 1 and player2 would be rank 2 player1 rank 3. My question is how would I get this rank for each player. Thanks for any help
coding in GChrome... something along the lines of this" Code:java ConfigFile config = Plugin.getConfig();int player1deaths = config.getInt("Player1.deaths");
load all player to HashMap Nickname, kills So when you have map of all scores Code: Map<String, Comparable> variableMap = new HashMap<>(); (you can change Comparable to other Object that is comparable, like Integer) And then use: Code: SortedMap<String, Comparable> sortedMap = ImmutableSortedMap.copyOf(variableMap, <one of two options>); But you have 2 options, sorting ASC or DESC so: Code: Ordering.natural().onResultOf(Functions.forMap(variableMap)).compound(Ordering.natural()); or Code: Ordering.natural().reverse().onResultOf(Functions.forMap(variableMap)).compound(Ordering.natural().reverse()); like: Code:java SortedMap<String, Comparable> sortedMap = ImmutableSortedMap.copyOf(variableMap, Ordering.natural().reverse().onResultOf(Functions.forMap(variableMap)).compound(Ordering.natural().reverse())); But is much better to use MySQL or LiteSQL That is good when you can't use SQLite because is only temporally data and that have no sense to add it to SQLite for 0.01 seconds
Smerfa Thanks but, since you are recommending MySQL do you have a link or something where i can learn how to use it?