Java tutorial
//package com.java2s; import android.support.annotation.Nullable; public class Main { public static int compareFloats(@Nullable Float one, @Nullable Float another, boolean ascending) { return one != null ? (another != null ? !ascending ? (int) Math.signum(another - one) : (int) Math.signum(one - another) : 1) : -1; } }