return preferredComparator(matches("[-|]P[-|]").negate(), (result) -> result.bot().name());
}
- /**
- * {@link Comparator} for {@link Result}s that sorts them by the name of the
- * {@link Pack}.
- */
- private static final Comparator<Result> packNameComparator = new Comparator<Result>() {
- @Override
- public int compare(Result leftResult, Result rightResult) {
- return leftResult.pack().name().compareToIgnoreCase(rightResult.pack().name());
- }
- };
+ private static final Comparator<Result> packNameComparator = sortRepacksFirst().thenComparing(sortPacksAlphabetically());
+
+ private static Comparator<Result> sortRepacksFirst() {
+ return preferredComparator(matches("\\.(PROPER|REPACK)\\."), (result) -> result.pack().name());
+ }
+
+ private static Comparator<Result> sortPacksAlphabetically() {
+ return new Comparator<Result>() {
+ @Override
+ public int compare(Result leftResult, Result rightResult) {
+ return leftResult.pack().name().compareToIgnoreCase(rightResult.pack().name());
+ }
+ };
+ }
/** Comparator that sorts bots with running downloads to the back of the list. */
private final Comparator<Result> botsWithRunningTransfersComparator = new Comparator<Result>() {