int (@NotNull TagInfo<?> other) { if (offset != other.offset) { return Integer.compare(offset, other.offset); } if (isStart != other.isStart) { // All "starts" should go after "ends" for same offset return isStart ? -1 : 1; } if (isFixed || other.isFixed) { return 0; } String thisTag = this.getName() + this.getAttributesString(); String otherTag = other.getName() + other.getAttributesString(); // Invert order for end tags return thisTag.compareTo(otherTag) * (isStart ? -1 : 1); }