int (NodeDescriptor o1, NodeDescriptor o2) { final int w1 = getWeight(o1); final int w2 = getWeight(o2); if (myCompareToString && w1 == w2) { return compareToString(o1, o2); } int weights = compareWeights(w1, w2); return weights != 0 ? weights : o1.getIndex() - o2.getIndex(); }