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

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

import androidx.annotation.NonNull;

import java.util.Locale;


    @Override
    protected boolean canCompare(cgCache cache1, cgCache cache2) {
        return cache1.getTerrain() != null && cache2.getTerrain() != null;
    }

    @Override
        return cache.getTerrain() != 0.0;
    }

    @Override
    protected int compareCaches(final Geocache cache1, final Geocache cache2) {
        return Float.compare(cache1.getTerrain(), cache2.getTerrain());
    }

    @Override
    public String getSortableSection(@NonNull final Geocache cache) {
        return String.format(Locale.getDefault(), "%.1f", cache.getTerrain());
    }

    @Override
    public void addSortToSql(final SqlBuilder sql, final boolean sortDesc) {
        sql.addOrder(sql.getMainTableId() + ".terrain", sortDesc);
    }

}

<MSG> refactoring: reduce boxing/unboxing craziness
<DFF> @@ -10,7 +10,7 @@ public class TerrainComparator extends AbstractCacheComparator {
 
     @Override
     protected boolean canCompare(cgCache cache1, cgCache cache2) {
-        return cache1.getTerrain() != null && cache2.getTerrain() != null;
+        return cache1.getTerrain() != 0.0 && cache2.getTerrain() != 0.0;
     }
 
     @Override

refactoring: reduce boxing/unboxing craziness