public static List<Dependency> sortDependencies(Collection<Dependency> dependencies) {
    List<Dependency> result = new LinkedList<>();
    for (Dependency dep : dependencies) {
      boolean added = false;
      for (int i = 0; i < result.size(); i++) {
        Dependency other = result.get(i);
        if (other.depender.equals(dep.depender)) {
          result.add(i, dep);
          added = true;
          break;
        }
        if (other.depender.equals(dep.dependsOn)) {
          result.add(i, dep);
          added = true;
          break;
        }
      }
      if (!added) {
        result.add(dep);
      }
    }
    return result;
  }
attempts to sort the given dependencies according to their contents so that dependents come
after dependers.

@param dependencies TODO this method needs more work
geode-core/src/main/java/org/apache/geode/distributed/internal/deadlock/DeadlockDetector.java