sort server count in the table
All checks were successful
Fetch new Pia Servers / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 16s

This commit is contained in:
Lee 2024-04-27 06:13:01 +01:00
parent 2eef36653d
commit 38e3fd14d1

@ -42,6 +42,7 @@ public class ReadMeManager {
regionCounts.put(region, regionCounts.getOrDefault(region, 0) + 1); regionCounts.put(region, regionCounts.getOrDefault(region, 0) + 1);
} }
contents = contents.replace("{server_table}", regionCounts.entrySet().stream() 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 .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 .reduce((a, b) -> a + "\n" + b).orElse("")); // Reduce the entries to a single string