Source:
<code>public static Pair<ClassificationCounter, List<AttributeValueWithClassificationCounter>> getSortedListOfAttributeValuesWithClassificationCounters( final Iterable<? extends Instance<AttributesMap>> instances, final String attribute, String splitAttribute, Serializable splitAttributeValue, final Serializable minorityClassification) { Pair<ClassificationCounter, Map<Serializable, ClassificationCounter>> totalsClassificationCounterPairedWithMapofClassificationCounters = countAllByAttributeValues(instances,attribute,splitAttribute,splitAttributeValue); final Map<Serializable, ClassificationCounter> result = totalsClassificationCounterPairedWithMapofClassificationCounters.getValue1(); final ClassificationCounter totals = totalsClassificationCounterPairedWithMapofClassificationCounters.getValue0(); List<AttributeValueWithClassificationCounter> attributesWithClassificationCounters = Lists.newArrayList(); for(Serializable key : result.keySet()) { attributesWithClassificationCounters.add(new AttributeValueWithClassificationCounter(key, result.get(key))); } Collections.sort(attributesWithClassificationCounters, new Comparator<AttributeValueWithClassificationCounter>() { @Override public int compare(AttributeValueWithClassificationCounter cc1, AttributeValueWithClassificationCounter cc2) { double probOfMinority1 = cc1.classificationCounter.getCount(minorityClassification) / cc1.classificationCounter.getTotal(); double probOfMinority2 = cc2.classificationCounter.getCount(minorityClassification) / cc2.classificationCounter.getTotal(); <START> return -Double.compare(probOfMinority1, probOfMinority2); <END> } }); return Pair.with(totals, attributesWithClassificationCounters); }</code><technical_language>this instead: <LINK_0> clearer more readable (the - return statement easily overlooked). So, Ordering.natural().reverse().compare(probOfMinority1, probOfMinority2);</technical_language>

Target:
public static Pair<ClassificationCounter, List<AttributeValueWithClassificationCounter>> getSortedListOfAttributeValuesWithClassificationCounters( final Iterable<? extends Instance<AttributesMap>> instances, final String attribute, String splitAttribute, Serializable splitAttributeValue, final Serializable minorityClassification) { Pair<ClassificationCounter, Map<Serializable, ClassificationCounter>> totalsClassificationCounterPairedWithMapofClassificationCounters = countAllByAttributeValues(instances,attribute,splitAttribute,splitAttributeValue); final Map<Serializable, ClassificationCounter> result = totalsClassificationCounterPairedWithMapofClassificationCounters.getValue1(); final ClassificationCounter totals = totalsClassificationCounterPairedWithMapofClassificationCounters.getValue0(); List<AttributeValueWithClassificationCounter> attributesWithClassificationCounters = Lists.newArrayList(); for(Serializable key : result.keySet()) { attributesWithClassificationCounters.add(new AttributeValueWithClassificationCounter(key, result.get(key))); } Collections.sort(attributesWithClassificationCounters, new Comparator<AttributeValueWithClassificationCounter>() { @Override public int compare(AttributeValueWithClassificationCounter cc1, AttributeValueWithClassificationCounter cc2) { double probOfMinority1 = cc1.classificationCounter.getCount(minorityClassification) / cc1.classificationCounter.getTotal(); double probOfMinority2 = cc2.classificationCounter.getCount(minorityClassification) / cc2.classificationCounter.getTotal(); return Ordering.natural().reverse().compare(probOfMinority1, probOfMinority2); } }); return Pair.with(totals, attributesWithClassificationCounters); }