SortedMap<Long, Collection<HRegion>> getCopyOfOnlineRegionsSortedByOnHeapSize() {
    // we'll sort the regions in reverse
    SortedMap<Long, Collection<HRegion>> sortedRegions = new TreeMap<>(Comparator.reverseOrder());
    // Copy over all regions. Regions are sorted by size with biggest first.
    for (HRegion region : this.onlineRegions.values()) {
      addRegion(sortedRegions, region, region.getMemStoreHeapSize());
    }
    return sortedRegions;
  }
@return A new Map of online regions sorted by region heap size with the first entry being the
        biggest.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java