docs: public void sortRelations(CmsObject cms, CmsResourceStatusBean resStatus) {
  
          final List<CmsSite> sites = OpenCms.getSiteManager().getAvailableSites(
              cms,
              false,
              false,
              cms.getRequestContext().getOuFqn());
          Collections.sort(resStatus.getOtherSiteRelationSources(), new Comparator<CmsResourceStatusRelationBean>() {
  
              private Map<String, Integer> m_rankCache = Maps.newHashMap();
  
              public int compare(CmsResourceStatusRelationBean o1, CmsResourceStatusRelationBean o2) {
  
                  return ComparisonChain.start().compare(rank(o1), rank(o2)).compare(
                      o1.getSitePath(),
                      o2.getSitePath()).result();
  
              }
  
              public int rank(CmsResourceStatusRelationBean r) {
  
                  if (m_rankCache.containsKey(r.getSiteRoot())) {
                      return m_rankCache.get(r.getSiteRoot()).intValue();
                  }
  
                  int j = 0;
                  int result = Integer.MAX_VALUE;
                  for (CmsSite site : sites) {
                      if (site.getSiteRoot().equals(r.getSiteRoot())) {
                          result = j;
                          break;
                      }
                      j += 1;
                  }
  
                  m_rankCache.put(r.getSiteRoot(), new Integer(result));
                  return result;
              }
          });
          // sort relation sources by path, make sure all resources within .detailContainer folders show last
          Collections.sort(resStatus.getRelationSources(), new Comparator<CmsResourceStatusRelationBean>() {
  
              public int compare(CmsResourceStatusRelationBean arg0, CmsResourceStatusRelationBean arg1) {
  
                  if (arg0.getSitePath().matches(DETAIL_CONTAINER_PATTERN)) {
                      if (!arg1.getSitePath().matches(DETAIL_CONTAINER_PATTERN)) {
                          return 1;
                      }
                  } else if (arg1.getSitePath().matches(DETAIL_CONTAINER_PATTERN)) {
                      return -1;
                  }
                  return arg0.getSitePath().compareTo(arg1.getSitePath());
              }
  
          });
      }