Сортировка объектов в массиве по убыванию используя значение в HashMap содержащееся в объекте!
Есть класс Player он содержит в себе переменные privat String name (никнейм игрока), privat double statistic (общая статистика) и privat HashMap <String, Double> games ( где ключ - название игры, а значение статистика игрока по этой игре). При регистрации пользователя класс Player добавляется в Linked list. ВОПРОС!!! Как мне вывести список(или создать Array list и вывести его) по убыванию по какой то определенной игре, ориентируясь на значение в HashMap (Double)??? Но нужно чтобы на выходе был не только HashMap, а весь объект kласса Player
public class Player {
private String name;
private HashMap<String, Double> games;
private double statistic;
public Player() {
}
public Player(String name, HashMap<String, Double> games, double statistic) {
this.name = name;
this.games = games;
this.statistic = statistic;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setGames(HashMap<String, Double> games) {
this.games = games;
}
public HashMap<String, Double> getGames() {
return games;
}
public void setStatistic(double statistic) {
this.statistic = statistic;
}
public double getStatistic() {
return statistic;
}
@Override
public String toString() {
return "\nUser name: " + name + "\tUser games: " + games + "\tGeneral statistics: " + statistic;
}
public static void statisticMenu(LinkedList<Player> players) {
Scanner scanner = new Scanner(System.in);
Player player;
boolean exit = false;
int enter = 0;
String[] games = {"WarFace", "DOTA", "World of Warcraft", "Quake III", "Diablo III"};
ArrayList<Player> statList = new ArrayList<>();
while (exit != true) {
System.out.printf("\n1: ОБЩИЙ РЕЙТИНГ\n2: ПОИСК ПО ИГРОКУ\n3: ПОИСК ПО ИГРЕ\n4: НАЗАД\n");
switch (enter = scanner.nextInt()) {
case 1:
break;
case 2:
System.out.printf("\nВведите ник игрока:\n");
break;
case 3:
System.out.printf("\nВыберите игру:\n");
while (exit != true) {
for (int i = 0; i < games.length; i++) {
System.out.printf("\n[" + (i + 1) + "] " + games[i]);
}
System.out.printf("\n[6] НАЗАД\n");
int num = scanner.nextInt();
if (num == 6) {
exit = true;
} else if (num < 1 || num > 6) {
System.out.printf("\nНекорректный ввод!!! Выберите игру или выйдите в ГЛАВНОЕ МЕНЮ!\n");
} else {
System.out.printf("\n\t\tСТАТИСТИКА " + games[num - 1].toUpperCase());
for (int i = 0; i < players.size(); i++) {
// String list = players.get(i).toString();
player = players.get(i);
if (player.getGames().containsKey(games[num - 1])) {
statList.add(player);
}
else if (i == (players.size() - 1) && statList.size() == 0) {
System.out.printf("\nИгроков играющих в эту игру пока НЕТ");
}
}
}
//СОРТИРОВКА ДОЛЖНА БЫТЬ ЗДЕСЬ!!!
System.out.printf("\n array " + statList.toString());
statList.clear();
}
exit = false;
break;
case 4:
exit = true;
break;
default:
System.out.printf("\nНекорректный ввод!!! Выберите пункт (1-4)\n");
break;
}
}
}