From d60f819fb71028f2793f5780c05f33e0bed09b73 Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Fri, 27 Dec 2024 22:00:32 +1100 Subject: [PATCH] Sort Unbound First --- .../nomiceu/nomilabs/integration/betterp2p/SortModes.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nomiceu/nomilabs/integration/betterp2p/SortModes.java b/src/main/java/com/nomiceu/nomilabs/integration/betterp2p/SortModes.java index 2032a128..bf22233f 100644 --- a/src/main/java/com/nomiceu/nomilabs/integration/betterp2p/SortModes.java +++ b/src/main/java/com/nomiceu/nomilabs/integration/betterp2p/SortModes.java @@ -49,7 +49,13 @@ private static Comparator compDefault(InfoWrapper selected) { if (b.getFrequency() == selected.getFrequency()) return 1; } - if (a.getFrequency() != b.getFrequency()) return b.getFrequency() - a.getFrequency(); + if (a.getFrequency() != b.getFrequency()) { + // Unbound first + if (a.getFrequency() == 0) return -1; + if (b.getFrequency() == 0) return 1; + + return b.getFrequency() - a.getFrequency(); + } return compareTypeThenDist(a, b); };