void (@Nullable List<? extends FrameworkSupportNodeBase> nodes, @Nullable final Comparator<? super FrameworkSupportNodeBase> comparator) { if (nodes == null) return; nodes.sort((o1, o2) -> { if (comparator != null) { int compare = comparator.compare(o1, o2); if (compare != 0) return compare; } if (o1 instanceof FrameworkGroupNode && !(o2 instanceof FrameworkGroupNode)) return -1; if (o2 instanceof FrameworkGroupNode && !(o1 instanceof FrameworkGroupNode)) return 1; if (o1.getChildCount() < o2.getChildCount()) return 1; if (o1.getChildCount() > o2.getChildCount()) return -1; return o1.getTitle().compareToIgnoreCase(o2.getTitle()); }); for (FrameworkSupportNodeBase<?> node : nodes) { @SuppressWarnings({"unchecked", "rawtypes"}) List<FrameworkSupportNodeBase<?>> children = (List)node.children; sortByName(children, null); } }