public int compare(LayoutInfo i1, LayoutInfo i2) { LayoutBox box1 = i1.getExactLayoutBox(); LayoutBox box2 = i2.getExactLayoutBox(); return (box1.size() < box2.size() ? -1 : (box1.size() == box2.size() ? 0 : 1)); }