private int compareUnit(App a) { if (!hasUnit()) return a.hasUnit() ? 1 : compareAppapp(a); else if (!a.hasUnit()) return -1; else { int c = unit.compareTo(a.getUnit()); return c != 0 ? c : compareAppapp(a); } }