mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-11 16:26:22 +00:00
Cleanup - Collections.sort -> list.sort
This commit is contained in:
@@ -666,7 +666,7 @@ public class AiController {
|
||||
List<SpellAbility> all = ComputerUtilAbility.getSpellAbilities(cards, player);
|
||||
|
||||
try {
|
||||
Collections.sort(all, ComputerUtilAbility.saEvaluator); // put best spells first
|
||||
all.sort(ComputerUtilAbility.saEvaluator); // put best spells first
|
||||
ComputerUtilAbility.sortCreatureSpells(all);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
System.err.println(ex.getMessage());
|
||||
@@ -1589,7 +1589,7 @@ public class AiController {
|
||||
return null;
|
||||
|
||||
try {
|
||||
Collections.sort(all, ComputerUtilAbility.saEvaluator); // put best spells first
|
||||
all.sort(ComputerUtilAbility.saEvaluator); // put best spells first
|
||||
ComputerUtilAbility.sortCreatureSpells(all);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
System.err.println(ex.getMessage());
|
||||
|
||||
@@ -965,7 +965,7 @@ public class ComputerUtilCard {
|
||||
if (color.hasGreen()) map.get(4).setValue(map.get(4).getValue() + 1);
|
||||
}
|
||||
|
||||
Collections.sort(map, Comparator.<Pair<Byte, Integer>>comparingInt(Pair::getValue).reversed());
|
||||
map.sort(Comparator.<Pair<Byte, Integer>>comparingInt(Pair::getValue).reversed());
|
||||
|
||||
// will this part be once dropped?
|
||||
List<String> result = new ArrayList<>(cntColors);
|
||||
|
||||
@@ -791,7 +791,7 @@ public class SpecialCardAi {
|
||||
sa.getParamOrDefault("ChangeNum", "1"), sa);
|
||||
CardCollection lib = CardLists.filter(ai.getCardsIn(ZoneType.Library),
|
||||
Predicates.not(CardPredicates.nameEquals(sa.getHostCard().getName())));
|
||||
Collections.sort(lib, CardLists.CmcComparatorInv);
|
||||
lib.sort(CardLists.CmcComparatorInv);
|
||||
|
||||
// Additional cards which are difficult to auto-classify but which are generally good to Intuition for
|
||||
List<String> highPriorityNamedCards = Lists.newArrayList("Accumulated Knowledge", "Take Inventory");
|
||||
@@ -888,7 +888,7 @@ public class SpecialCardAi {
|
||||
// If we're playing Reanimator, we're really interested just in the highest CMC spells, not the
|
||||
// ones we necessarily have multiples of
|
||||
if (ComputerUtil.isPlayingReanimator(ai)) {
|
||||
Collections.sort(libHighPriorityList, CardLists.CmcComparatorInv);
|
||||
libHighPriorityList.sort(CardLists.CmcComparatorInv);
|
||||
}
|
||||
|
||||
// Otherwise, try to grab something that is hopefully decent to grab, in priority order
|
||||
@@ -1502,7 +1502,7 @@ public class SpecialCardAi {
|
||||
if (atTargetCMCInLib.isEmpty()) {
|
||||
atTargetCMCInLib = CardLists.filter(creatsInLib, CardPredicates.greaterCMC(numManaSrcs));
|
||||
}
|
||||
Collections.sort(atTargetCMCInLib, CardLists.CmcComparatorInv);
|
||||
atTargetCMCInLib.sort(CardLists.CmcComparatorInv);
|
||||
if (atTargetCMCInLib.isEmpty()) {
|
||||
// Nothing to aim for?
|
||||
return null;
|
||||
@@ -1510,11 +1510,11 @@ public class SpecialCardAi {
|
||||
|
||||
// Cards in hand that are below the max CMC affordable by the AI
|
||||
CardCollection belowMaxCMC = CardLists.filter(creatsInHand, CardPredicates.lessCMC(numManaSrcs - 1));
|
||||
Collections.sort(belowMaxCMC, Collections.reverseOrder(CardLists.CmcComparatorInv));
|
||||
belowMaxCMC.sort(Collections.reverseOrder(CardLists.CmcComparatorInv));
|
||||
|
||||
// Cards in hand that are above the max CMC affordable by the AI
|
||||
CardCollection aboveMaxCMC = CardLists.filter(creatsInHand, CardPredicates.greaterCMC(numManaSrcs + 1));
|
||||
Collections.sort(aboveMaxCMC, CardLists.CmcComparatorInv);
|
||||
aboveMaxCMC.sort(CardLists.CmcComparatorInv);
|
||||
|
||||
Card maxCMC = !aboveMaxCMC.isEmpty() ? aboveMaxCMC.getFirst() : null;
|
||||
Card minCMC = !belowMaxCMC.isEmpty() ? belowMaxCMC.getFirst() : null;
|
||||
@@ -1547,7 +1547,7 @@ public class SpecialCardAi {
|
||||
// worth to fill the graveyard now
|
||||
if (ComputerUtil.isPlayingReanimator(ai) && !creatsInLib.isEmpty()) {
|
||||
CardCollection creatsInHandByCMC = new CardCollection(creatsInHand);
|
||||
Collections.sort(creatsInHandByCMC, CardLists.CmcComparatorInv);
|
||||
creatsInHandByCMC.sort(CardLists.CmcComparatorInv);
|
||||
return creatsInHandByCMC.getFirst();
|
||||
}
|
||||
|
||||
@@ -1569,14 +1569,14 @@ public class SpecialCardAi {
|
||||
if (atTargetCMCInLib.isEmpty()) {
|
||||
atTargetCMCInLib = CardLists.filter(creatsInLib, CardPredicates.greaterCMC(numManaSrcs));
|
||||
}
|
||||
Collections.sort(atTargetCMCInLib, CardLists.CmcComparatorInv);
|
||||
atTargetCMCInLib.sort(CardLists.CmcComparatorInv);
|
||||
|
||||
Card bestInLib = atTargetCMCInLib != null ? atTargetCMCInLib.getFirst() : null;
|
||||
|
||||
if (bestInLib == null && ComputerUtil.isPlayingReanimator(ai)) {
|
||||
// For Reanimator, we don't mind grabbing the biggest thing possible to recycle it again with SotF later.
|
||||
CardCollection creatsInLibByCMC = new CardCollection(creatsInLib);
|
||||
Collections.sort(creatsInLibByCMC, CardLists.CmcComparatorInv);
|
||||
creatsInLibByCMC.sort(CardLists.CmcComparatorInv);
|
||||
return creatsInLibByCMC.getFirst();
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
||||
result.add(c.getKey());
|
||||
}
|
||||
if (result.size() > 1) { //sort by type so signature spell comes after oathbreaker
|
||||
Collections.sort(result, Comparator.comparing(c -> c.getRules().canBeSignatureSpell()));
|
||||
result.sort(Comparator.comparing(c -> c.getRules().canBeSignatureSpell()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class DeckGroup extends DeckBase {
|
||||
if (aiDecks.size() < 2) {
|
||||
return;
|
||||
}
|
||||
Collections.sort(aiDecks, comparator);
|
||||
aiDecks.sort(comparator);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -525,7 +525,7 @@ public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>,
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void sort(final Comparator<? super T> comparator) {
|
||||
Collections.sort(list, comparator);
|
||||
list.sort(comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -133,7 +133,7 @@ public final class MapToAmountUtil {
|
||||
for (final Entry<T, Integer> entry : map.entrySet()) {
|
||||
entries.add(Pair.of(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
Collections.sort(entries, Entry.comparingByValue());
|
||||
entries.sort(Entry.comparingByValue());
|
||||
return entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -1143,7 +1143,7 @@ public class GameAction {
|
||||
.compareTrueFirst(a.hasParam("CharacteristicDefining"), b.hasParam("CharacteristicDefining"))
|
||||
.compare(a.getHostCard().getLayerTimestamp(), b.getHostCard().getLayerTimestamp())
|
||||
.result();
|
||||
Collections.sort(staticAbilities, comp);
|
||||
staticAbilities.sort(comp);
|
||||
|
||||
final Map<StaticAbility, CardCollectionView> affectedPerAbility = Maps.newHashMap();
|
||||
for (final StaticAbilityLayer layer : StaticAbilityLayer.CONTINUOUS_LAYERS) {
|
||||
|
||||
@@ -465,9 +465,8 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
super("Format collections", reader);
|
||||
naturallyOrdered = reader.naturallyOrdered;
|
||||
reverseDateOrdered = new ArrayList<>(naturallyOrdered);
|
||||
Collections.sort(naturallyOrdered);
|
||||
//Why this refactor doesnt work on some android phones? -> reverseDateOrdered.sort(new InverseDateComparator());
|
||||
Collections.sort(reverseDateOrdered, new InverseDateComparator());
|
||||
naturallyOrdered.sort(Comparator.naturalOrder());
|
||||
reverseDateOrdered.sort(new InverseDateComparator());
|
||||
}
|
||||
|
||||
public Iterable<GameFormat> getOrderedList() {
|
||||
|
||||
@@ -80,7 +80,7 @@ public class CardLists {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByCmcDesc(final List<Card> list) {
|
||||
Collections.sort(list, CmcComparatorInv);
|
||||
list.sort(CmcComparatorInv);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +91,7 @@ public class CardLists {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByToughnessAsc(final List<Card> list) {
|
||||
Collections.sort(list, ToughnessComparator);
|
||||
list.sort(ToughnessComparator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +102,7 @@ public class CardLists {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByToughnessDesc(final List<Card> list) {
|
||||
Collections.sort(list, ToughnessComparatorInv);
|
||||
list.sort(ToughnessComparatorInv);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ public class CardLists {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByPowerAsc(final List<Card> list) {
|
||||
Collections.sort(list, PowerComparator);
|
||||
list.sort(PowerComparator);
|
||||
}
|
||||
|
||||
// the higher the attack the better
|
||||
@@ -125,7 +125,7 @@ public class CardLists {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByPowerDesc(final List<Card> list) {
|
||||
Collections.sort(list, Collections.reverseOrder(PowerComparator));
|
||||
list.sort(Collections.reverseOrder(PowerComparator));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -118,7 +118,7 @@ public class Cost implements Serializable {
|
||||
// Things that are pretty much happen at the end (Untap) 16+
|
||||
// Things that NEED to happen last 100+
|
||||
|
||||
Collections.sort(this.costParts, (o1, o2) -> ObjectUtils.compare(o1.paymentOrder(), o2.paymentOrder()));
|
||||
this.costParts.sort((o1, o2) -> ObjectUtils.compare(o1.paymentOrder(), o2.paymentOrder()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -160,7 +160,7 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
||||
columns.add(colOverrides.get(colConfig.getDef()));
|
||||
}
|
||||
}
|
||||
Collections.sort(columns, Comparator.comparingInt(ItemTableColumn::getIndex));
|
||||
columns.sort(Comparator.comparingInt(ItemTableColumn::getIndex));
|
||||
|
||||
//hide table header if only showing single string column
|
||||
final boolean hideHeader = (config.getCols().size() == 1 && config.getCols().containsKey(ColumnDef.STRING));
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ContestGauntletLister extends JPanel {
|
||||
this.removeAll();
|
||||
final List<RowPanel> tempRows = new ArrayList<>();
|
||||
final List<GauntletData> sorted = new ArrayList<>(gd0);
|
||||
Collections.sort(sorted, Comparator.comparing(GauntletData::getName));
|
||||
sorted.sort(Comparator.comparing(GauntletData::getName));
|
||||
|
||||
// Title row
|
||||
// Note: careful with the widths of the rows here;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class QuickGauntletLister extends JPanel {
|
||||
this.removeAll();
|
||||
final List<RowPanel> tempRows = new ArrayList<>();
|
||||
final List<GauntletData> sorted = new ArrayList<>(gauntlets);
|
||||
Collections.sort(sorted, Comparator.comparing(x -> x.getName().toLowerCase()));
|
||||
sorted.sort(Comparator.comparing(x -> x.getName().toLowerCase()));
|
||||
|
||||
// Title row
|
||||
// Note: careful with the widths of the rows here;
|
||||
|
||||
@@ -77,7 +77,7 @@ public class QuestFileLister extends JPanel {
|
||||
this.removeAll();
|
||||
List<RowPanel> tempRows = new ArrayList<>();
|
||||
List<QuestData> sorted = new ArrayList<>(qd0);
|
||||
Collections.sort(sorted, Comparator.comparing(x -> x.getName().toLowerCase()));
|
||||
sorted.sort(Comparator.comparing(x -> x.getName().toLowerCase()));
|
||||
|
||||
// Title row
|
||||
// Note: careful with the widths of the rows here;
|
||||
|
||||
@@ -147,7 +147,7 @@ public class FloatingZone extends FloatingCardArea {
|
||||
if (zoneCards != null) {
|
||||
cardList = new FCollection<>(zoneCards);
|
||||
if (sortedByName) {
|
||||
Collections.sort(cardList, comp);
|
||||
cardList.sort(comp);
|
||||
}
|
||||
return cardList;
|
||||
} else {
|
||||
|
||||
@@ -207,7 +207,7 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
|
||||
cols.add(colOverrides.get(colConfig.getDef()));
|
||||
}
|
||||
}
|
||||
Collections.sort(cols, Comparator.comparingInt(arg0 -> arg0.getConfig().getIndex()));
|
||||
cols.sort(Comparator.comparingInt(arg0 -> arg0.getConfig().getIndex()));
|
||||
|
||||
sortCols.clear();
|
||||
if (cbxSortOptions != null) {
|
||||
|
||||
@@ -274,7 +274,7 @@ public class LoadGauntletScreen extends LaunchScreen {
|
||||
|
||||
public void refresh() {
|
||||
List<GauntletData> sorted = new ArrayList<>(gauntlets);
|
||||
Collections.sort(sorted, Comparator.comparing(x -> x.getName().toLowerCase()));
|
||||
sorted.sort(Comparator.comparing(x -> x.getName().toLowerCase()));
|
||||
setListData(sorted);
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@ public class LoadConquestScreen extends LaunchScreen {
|
||||
|
||||
public void setConquests(List<ConquestData> qd0) {
|
||||
List<ConquestData> sorted = new ArrayList<>(qd0);
|
||||
Collections.sort(sorted, Comparator.comparing(x -> x.getName().toLowerCase()));
|
||||
sorted.sort(Comparator.comparing(x -> x.getName().toLowerCase()));
|
||||
setListData(sorted);
|
||||
}
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ public class LoadQuestScreen extends LaunchScreen {
|
||||
|
||||
public void setQuests(List<QuestData> qd0) {
|
||||
List<QuestData> sorted = new ArrayList<>(qd0);
|
||||
Collections.sort(sorted, Comparator.comparing(x -> x.getName().toLowerCase()));
|
||||
sorted.sort(Comparator.comparing(x -> x.getName().toLowerCase()));
|
||||
setListData(sorted);
|
||||
}
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ public class GuiChoose {
|
||||
// If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine
|
||||
public static <T> void sortedGetChoices(final String message, final int min, final int max, final List<T> choices, Comparator<T> comparer, final Callback<List<T>> callback) {
|
||||
// You may create a copy of source list if callers expect the collection to be unchanged
|
||||
Collections.sort(choices, comparer);
|
||||
choices.sort(comparer);
|
||||
getChoices(message, min, max, choices, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public class BoosterDraft implements IBoosterDraft {
|
||||
if (myDrafts.isEmpty()) {
|
||||
SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblNotFoundCustomDraftFiles"));
|
||||
} else {
|
||||
Collections.sort(myDrafts, Comparator.comparing(DeckBase::getName));
|
||||
myDrafts.sort(Comparator.comparing(DeckBase::getName));
|
||||
|
||||
final CustomLimited customDraft = SGuiChoose.oneOrNone(Localizer.getInstance().getMessage("lblChooseCustomDraft"), myDrafts);
|
||||
if (customDraft == null) {
|
||||
|
||||
@@ -134,7 +134,7 @@ public class HostedMatch {
|
||||
}
|
||||
|
||||
final List<RegisteredPlayer> sortedPlayers = Lists.newArrayList(players);
|
||||
Collections.sort(sortedPlayers, (p1, p2) -> {
|
||||
sortedPlayers.sort((p1, p2) -> {
|
||||
|
||||
final int v1 = p1.getPlayer() instanceof LobbyPlayerHuman ? 0 : 1;
|
||||
final int v2 = p2.getPlayer() instanceof LobbyPlayerHuman ? 0 : 1;
|
||||
|
||||
@@ -215,7 +215,7 @@ final class GameClientHandler extends GameProtocolHandler<IGuiGame> {
|
||||
}
|
||||
|
||||
final List<RegisteredPlayer> sortedPlayers = Lists.newArrayList(players);
|
||||
Collections.sort(sortedPlayers, (p1, p2) -> {
|
||||
sortedPlayers.sort((p1, p2) -> {
|
||||
final int v1 = p1.getPlayer() instanceof LobbyPlayerHuman ? 0 : 1;
|
||||
final int v2 = p2.getPlayer() instanceof LobbyPlayerHuman ? 0 : 1;
|
||||
return Integer.compare(v1, v2);
|
||||
|
||||
@@ -580,8 +580,8 @@ public final class BoosterUtils {
|
||||
|
||||
public static void sort(List<PaperCard> cards) {
|
||||
//sort cards alphabetically so colors appear together and rares appear on top
|
||||
Collections.sort(cards, Comparator.comparing(PaperCard::getName));
|
||||
Collections.sort(cards, Comparator.comparing(c -> c.getRules().getColor()));
|
||||
Collections.sort(cards, Comparator.comparing(PaperCard::getRarity).reversed());
|
||||
cards.sort(Comparator.comparing(PaperCard::getName));
|
||||
cards.sort(Comparator.comparing(c -> c.getRules().getColor()));
|
||||
cards.sort(Comparator.comparing(PaperCard::getRarity).reversed());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1003,7 +1003,7 @@ public class QuestEventDraft implements IQuestEvent {
|
||||
}
|
||||
|
||||
final boolean oldSetsFirst = sets.get(0).getDate().before(FModel.getMagicDb().getEditions().get("SOM").getDate());
|
||||
Collections.sort(allowedSets, (edition1, edition2) -> {
|
||||
allowedSets.sort((edition1, edition2) -> {
|
||||
if (edition1.getDate().before(edition2.getDate())) {
|
||||
return oldSetsFirst ? -1 : 1;
|
||||
} else if (edition1.getDate().after(edition2.getDate())) {
|
||||
|
||||
@@ -167,7 +167,7 @@ public class QuestUtilUnlockSets {
|
||||
}
|
||||
|
||||
// sort by distance, then by code desc
|
||||
Collections.sort(excludedWithDistances, (o1, o2) -> {
|
||||
excludedWithDistances.sort((o1, o2) -> {
|
||||
long delta = o2.right - o1.right;
|
||||
return delta < 0 ? -1 : delta == 0 ? 0 : 1;
|
||||
});
|
||||
|
||||
@@ -107,11 +107,11 @@ public abstract class AbstractTournament implements Serializable {
|
||||
|
||||
public void sortAllPlayers(String sortType) {
|
||||
if (sortType.equals("score")) {
|
||||
Collections.sort(allPlayers, (o1, o2) -> o2.getScore() - o1.getScore());
|
||||
allPlayers.sort((o1, o2) -> o2.getScore() - o1.getScore());
|
||||
} else if (sortType.equals("index")) {
|
||||
Collections.sort(allPlayers, (o1, o2) -> o2.getIndex() - o1.getIndex());
|
||||
allPlayers.sort((o1, o2) -> o2.getIndex() - o1.getIndex());
|
||||
} else if (sortType.equals("swiss")) {
|
||||
Collections.sort(allPlayers, (o1, o2) -> o2.getSwissScore() - o1.getSwissScore());
|
||||
allPlayers.sort((o1, o2) -> o2.getSwissScore() - o1.getSwissScore());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ public class TournamentSwiss extends AbstractTournament {
|
||||
return pairSwissGroup(players);
|
||||
}
|
||||
|
||||
Collections.sort(players, Comparator.comparingInt(o -> availableOpponents.get(o).size()));
|
||||
players.sort(Comparator.comparingInt(o -> availableOpponents.get(o).size()));
|
||||
|
||||
while (players.size() > 1) {
|
||||
TournamentPlayer initialPlayer = players.get(0);
|
||||
|
||||
@@ -297,7 +297,7 @@ public class AdvancedSearch {
|
||||
List<PaperCard> cards = FModel.getMagicDb().getCommonCards().getAllCards(input.getName());
|
||||
if (cards.size() <= 1) { return true; }
|
||||
|
||||
Collections.sort(cards, FModel.getMagicDb().getEditions().CARD_EDITION_COMPARATOR);
|
||||
cards.sort(FModel.getMagicDb().getEditions().CARD_EDITION_COMPARATOR);
|
||||
return cards.get(0) == input;
|
||||
}
|
||||
}),
|
||||
@@ -528,7 +528,7 @@ public class AdvancedSearch {
|
||||
List<PaperCard> cards = FModel.getMagicDb().getCommonCards().getAllCards(input.getName());
|
||||
if (cards.size() <= 1) { return true; }
|
||||
|
||||
Collections.sort(cards, FModel.getMagicDb().getEditions().CARD_EDITION_COMPARATOR);
|
||||
cards.sort(FModel.getMagicDb().getEditions().CARD_EDITION_COMPARATOR);
|
||||
return cards.get(0) == input;
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -124,7 +124,7 @@ public final class ItemManagerModel<T extends InventoryItem> {
|
||||
public void refreshSort() {
|
||||
final List<Entry<T, Integer>> list = getOrderedList();
|
||||
if (list.isEmpty()) { return; }
|
||||
try { Collections.sort(list, new MyComparator()); }
|
||||
try { list.sort(new MyComparator()); }
|
||||
//fix NewDeck editor not loading on Android if a user deleted unwanted sets on edition folder
|
||||
catch (IllegalArgumentException ex) {}
|
||||
}
|
||||
|
||||
@@ -1343,7 +1343,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
|
||||
// create sorted list from map from least to most frequent
|
||||
List<Entry<String, Integer>> sortedList = Lists.newArrayList(typesInDeck.entrySet());
|
||||
Collections.sort(sortedList, Entry.comparingByValue());
|
||||
sortedList.sort(Entry.comparingByValue());
|
||||
|
||||
// loop through sorted list and move each type to the front of the
|
||||
// validTypes collection
|
||||
|
||||
@@ -254,7 +254,7 @@ public final class LDAModelGenetrator {
|
||||
}
|
||||
Comparator<Archetype> archetypeComparator = (o1, o2) -> o2.getDeckCount().compareTo(o1.getDeckCount());
|
||||
|
||||
Collections.sort(unfilteredTopics,archetypeComparator);
|
||||
unfilteredTopics.sort(archetypeComparator);
|
||||
return unfilteredTopics;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ public final class LDAModelGenetrator {
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <K, V> Map<K, V> sortByValue(Map<K, V> map) {
|
||||
List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
|
||||
Collections.sort(list, (Comparator<Object>) (o1, o2) -> ((Comparable<V>) ((Map.Entry<K, V>) (o2)).getValue()).compareTo(((Map.Entry<K, V>) (o1)).getValue()));
|
||||
list.sort((Comparator<Object>) (o1, o2) -> ((Comparable<V>) ((Map.Entry<K, V>) (o2)).getValue()).compareTo(((Map.Entry<K, V>) (o1)).getValue()));
|
||||
|
||||
Map<K, V> result = new LinkedHashMap<>();
|
||||
for (Map.Entry<K, V> entry : list) {
|
||||
|
||||
Reference in New Issue
Block a user