protected <T extends OrderedOption>List<T> sortOptions(Collection<? extends T> options) {
    Set<String> names = new HashSet<>(ContainerUtil.map(options, option -> option.getOptionName()));

    List<T> order = new ArrayList<>(options.size());
    MultiMap<String, T> afters = new MultiMap<>();
    MultiMap<String, T> befores = new MultiMap<>();

    for (T each : options) {
        String anchorOptionName = each.getAnchorOptionName();
        if (anchorOptionName != null && names.contains(anchorOptionName)) {
          if (each.getAnchor() == OptionAnchor.AFTER) {
            afters.putValue(anchorOptionName, each);
            continue;
          }
          else if (each.getAnchor() == OptionAnchor.BEFORE) {
            befores.putValue(anchorOptionName, each);
            continue;
          }
        }
      order.add(each);
    }

    List<T> result = new ArrayList<>(options.size());
    for (T each : order) {
      result.addAll(befores.get(each.getOptionName()));
      result.add(each);
      result.addAll(afters.get(each.getOptionName()));
    }

    assert result.size() == options.size();
    return result;
  }
protected <T extends OrderedOption>List<T> sortOptions(Collection<? extends T> options)