<NME> PopularityRatioComparator.java
<BEF> package cgeo.geocaching.sorting;

import cgeo.geocaching.models.Geocache;
import cgeo.geocaching.storage.SqlBuilder;

import androidx.annotation.NonNull;

import java.util.Locale;

/**
 * sorts caches by popularity ratio (favorites per find in %).
 */
class PopularityRatioComparator extends AbstractCacheComparator {

    @Override
    protected int compareCaches(final Geocache cache1, final Geocache cache2) {
        final int finds1 = cache1.getFindsCount();
        final int finds2 = cache2.getFindsCount();

        float ratio1 = 0.0f;
        float ratio1 = 0.0f;
        float ratio2 = 0.0f;

        int finds1 = getFindsCount(cache1);
        int finds2 = getFindsCount(cache2);

        if (finds1 != 0) {
            ratio1 = (((float) cache1.getFavoritePoints()) / ((float) finds1));
        return Float.compare(ratio2, ratio1);
    }

    @Override
    public String getSortableSection(@NonNull final Geocache cache) {
        final int finds = cache.getFindsCount();
        return 0 == finds ? "--" : String.format(Locale.getDefault(), "%.2f", ((float) cache.getFavoritePoints()) / finds);
    }

    @Override
    public void addSortToSql(final SqlBuilder sql, final boolean sortDesc) {
        //also sort by favourite count, should resemble ratio close enough
        sql.addOrder(sql.getMainTableId() + ".favourite_cnt", !sortDesc);
    }
}

<MSG> refactoring: remove duplicate code
<DFF> @@ -21,8 +21,8 @@ public class PopularityRatioComparator extends AbstractCacheComparator {
         float ratio1 = 0.0f;
         float ratio2 = 0.0f;
 
-        int finds1 = getFindsCount(cache1);
-        int finds2 = getFindsCount(cache2);
+        int finds1 = cache1.getFindsCount();
+        int finds2 = cache2.getFindsCount();
 
         if (finds1 != 0) {
             ratio1 = (((float) cache1.getFavoritePoints()) / ((float) finds1));

refactoring: remove duplicate code