@Override
  public int compareTo(final @NotNull MemberIdentifier other, final boolean compareMemberData,
      final boolean compareViewIds) {
    int c = Integer.compare(getMembershipPort(), other.getMembershipPort());
    if (c != 0) {
      return c;
    }

    final InetAddress myAddr = getInetAddress();
    final InetAddress otherAddr = other.getInetAddress();

    // Discard null cases
    if (myAddr == null && otherAddr == null) {
      return 0;
    } else if (myAddr == null) {
      return -1;
    } else if (otherAddr == null) {
      return 1;
    }

    final byte[] myBytes = myAddr.getAddress();
    final byte[] otherBytes = otherAddr.getAddress();

    if (myBytes != otherBytes) {
      for (int i = 0; i < myBytes.length; i++) {
        if (i >= otherBytes.length) {
          return -1; // same as far as they go, but shorter...
        }
        if (myBytes[i] < otherBytes[i]) {
          return -1;
        }
        if (myBytes[i] > otherBytes[i]) {
          return 1;
        }
      }
      if (myBytes.length > otherBytes.length) {
        return 1; // same as far as they go, but longer...
      }
    }

    if (!(other.isPartial() || isPartial())) {
      c = StringUtils.compare(getName(), other.getName());
      if (c != 0) {
        return c;
      }
    }

    final String uniqueTag = getUniqueTag();
    final String otherUniqueTag = other.getUniqueTag();
    if (uniqueTag == null && otherUniqueTag == null) {
      if (compareViewIds) {
        // not loners, so look at P2P view ID
        final int thisViewId = getVmViewId();
        final int otherViewId = other.getVmViewId();
        if (thisViewId >= 0 && otherViewId >= 0) {
          c = Integer.compare(thisViewId, otherViewId);
          if (c != 0) {
            return c;
          }
        }
      }
    } else {
      c = StringUtils.compare(uniqueTag, otherUniqueTag);
      if (c != 0) {
        return c;
      }
    }

    if (compareMemberData && memberData != null && other.getMemberData() != null) {
      return memberData.compareAdditionalData(other.getMemberData());
    } else {
      return 0;
    }
  }
Returns the name of this member's distributed system connection or null if no name was
specified.
geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MemberIdentifierImpl.java