From 265159268d044d29437961c557701aedb7c083b1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 21 Jan 2014 08:05:19 +0100 Subject: [PATCH] Sort repacks to the front. --- .../net/pterodactylus/xdcc/ui/stdin/Result.java | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) 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() { -- 2.7.4