From: David ‘Bombe’ Roden Date: Tue, 21 Jan 2014 07:05:19 +0000 (+0100) Subject: Sort repacks to the front. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=265159268d044d29437961c557701aedb7c083b1;p=xudocci.git Sort repacks to the front. --- diff --git a/src/main/java/net/pterodactylus/xdcc/ui/stdin/Result.java b/src/main/java/net/pterodactylus/xdcc/ui/stdin/Result.java index 0107c6c..f7f0523 100644 --- a/src/main/java/net/pterodactylus/xdcc/ui/stdin/Result.java +++ b/src/main/java/net/pterodactylus/xdcc/ui/stdin/Result.java @@ -85,16 +85,20 @@ public class Result implements Comparable { 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 packNameComparator = new Comparator() { - @Override - public int compare(Result leftResult, Result rightResult) { - return leftResult.pack().name().compareToIgnoreCase(rightResult.pack().name()); - } - }; + private static final Comparator packNameComparator = sortRepacksFirst().thenComparing(sortPacksAlphabetically()); + + private static Comparator sortRepacksFirst() { + return preferredComparator(matches("\\.(PROPER|REPACK)\\."), (result) -> result.pack().name()); + } + + private static Comparator sortPacksAlphabetically() { + return new Comparator() { + @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 botsWithRunningTransfersComparator = new Comparator() {