private static int compareRegionInfosWithoutReplicaId(RegionInfo regionInfoA,
    RegionInfo regionInfoB) {
    int result = regionInfoA.getTable().compareTo(regionInfoB.getTable());
    if (result != 0) {
      return result;
    }

    // Compare start keys.
    result = Bytes.compareTo(regionInfoA.getStartKey(), regionInfoB.getStartKey());
    if (result != 0) {
      return result;
    }

    // Compare end keys.
    result = Bytes.compareTo(regionInfoA.getEndKey(), regionInfoB.getEndKey());

    if (result != 0) {
      if (regionInfoA.getStartKey().length != 0 && regionInfoA.getEndKey().length == 0) {
        return 1; // this is last region
      }
      if (regionInfoB.getStartKey().length != 0 && regionInfoB.getEndKey().length == 0) {
        return -1; // o is the last region
      }
      return result;
    }

    // regionId is usually milli timestamp -- this defines older stamps
    // to be "smaller" than newer stamps in sort order.
    if (regionInfoA.getRegionId() > regionInfoB.getRegionId()) {
      return 1;
    } else if (regionInfoA.getRegionId() < regionInfoB.getRegionId()) {
      return -1;
    }
    return 0;
  }
Removes the non-default replicas from the passed regions collection
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionReplicaUtil.java