private static List<RootModelImpl> getSortedChangedModels(
      Collection<ModifiableRootModel> rootModels, ModifiableModuleModel moduleModel) {
    List<RootModelImpl> result = ContainerUtil.newArrayListWithCapacity(rootModels.size());

    for (ModifiableRootModel model : rootModels) {
      RootModelImpl rootModel = (RootModelImpl) model;
      if (rootModel.isChanged()) {
        result.add(rootModel);
      }
    }

    DFSTBuilder<RootModelImpl> builder = createDFSTBuilder(result, moduleModel);
    Collections.sort(result, builder.comparator());

    return result;
  }
 static Comparator<IdeaPluginDescriptor> getPluginDescriptorComparator(
     Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap) {
   final Graph<PluginId> graph = createPluginIdGraph(idToDescriptorMap);
   final DFSTBuilder<PluginId> builder = new DFSTBuilder<PluginId>(graph);
   /*
   if (!builder.isAcyclic()) {
     final Pair<String,String> circularDependency = builder.getCircularDependency();
     throw new Exception("Cyclic dependencies between plugins are not allowed: \"" + circularDependency.getFirst() + "\" and \"" + circularDependency.getSecond() + "");
   }
   */
   final Comparator<PluginId> idComparator = builder.comparator();
   return new Comparator<IdeaPluginDescriptor>() {
     @Override
     public int compare(IdeaPluginDescriptor o1, IdeaPluginDescriptor o2) {
       return idComparator.compare(o1.getPluginId(), o2.getPluginId());
     }
   };
 }