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