@Override
	public int compareTo(AddressSpace space) {
		if (space == this) {
			return 0;
		}

		if (this instanceof OverlayAddressSpace thisOverlaySpace) {
			if (space instanceof OverlayAddressSpace otherOverlaySpace) {
				// Both spaces are overlay spaces
				return thisOverlaySpace.compareOverlay(otherOverlaySpace);
			}
			// I'm an overlay, other space is NOT an overlay
			return 1;
		}

		if (space instanceof OverlayAddressSpace) {
			// I'm NOT an overlay, other space is an overlay
			return -1;
		}

		if (hashCode() == space.hashCode() &&
			// hashcode factors name and type
			type == space.getType() && getName().equals(space.getName()) &&
			getClass().equals(space.getClass())) {
			// This is not intended to handle complete mixing of address spaces
			// from multiple sources (i.e., language provider / address factory).
			// It is intended to handle searching for a single address from one
			// source within a list/set of addresses from a second source.
			return 0;
		}

		int c = getSpaceID() - space.getSpaceID();
		if (c == 0) {
			c = getClass().getName().compareTo(space.getClass().getName());
		}
		return c;
	}
Returns the unique id value for this space.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/address/AbstractAddressSpace.java