private CacheComparator getComparatorFor(final SortType type, final boolean inverted) {
        final CacheComparator base;
        switch (type) {
            case AUTO:
                base = getComparatorFor(getAutoType(), false);
                break;
            case TARGET_DISTANCE:
                base = this.targetCoords != null ? new TargetDistanceComparator(this.targetCoords) : getComparatorFor(SortType.DISTANCE, false);
                break;
            default:
                base = type.cacheComparatorSupplier.get();
                break;
        }

        return inverted ? new InverseComparator(base) : base;
    }
Sets sort context depending on a list context.
main/src/main/java/cgeo/geocaching/sorting/GeocacheSort.java