static <T> int compare(@NotNull T o1, @NotNull T o2, @NotNull Function<? super T, String> nameExtractor) {
    if (o1 instanceof DisplayPrioritySortable) {
      if (o2 instanceof DisplayPrioritySortable d2) {
        DisplayPrioritySortable d1 = (DisplayPrioritySortable)o1;
        int result = (d1.getPriority()).compareTo(d2.getPriority());
        if (result != 0) return result;
        result = -Integer.compare(d1.getWeight(), d2.getWeight());
        if (result != 0) return result;
      }
      else {
        return -1;
      }
    }
    else if (o2 instanceof DisplayPrioritySortable) {
      return 1;
    }
    return StringUtil.compare(nameExtractor.apply(o1), nameExtractor.apply(o2), true);
  }
static <T> int compare(@NotNull T o1, @NotNull T o2, @NotNull Function<? super T, String> nameExtractor)