From 38e3fd14d16c9c3789dd06ad37b7073711f7053d Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 27 Apr 2024 06:13:01 +0100 Subject: [PATCH] sort server count in the table --- src/main/java/cc/fascinated/piaservers/readme/ReadMeManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/cc/fascinated/piaservers/readme/ReadMeManager.java b/src/main/java/cc/fascinated/piaservers/readme/ReadMeManager.java index 57ccfbc..02d066e 100644 --- a/src/main/java/cc/fascinated/piaservers/readme/ReadMeManager.java +++ b/src/main/java/cc/fascinated/piaservers/readme/ReadMeManager.java @@ -42,6 +42,7 @@ public class ReadMeManager { regionCounts.put(region, regionCounts.getOrDefault(region, 0) + 1); } contents = contents.replace("{server_table}", regionCounts.entrySet().stream() + .sorted((a, b) -> Integer.compare(b.getValue(), a.getValue())) // Sort from highest to lowest .map(entry -> "| " + entry.getKey() + " | " + entry.getValue() + " |") // Map the region to the count .reduce((a, b) -> a + "\n" + b).orElse("")); // Reduce the entries to a single string