void () { myModel.addSorter(new Sorter() { @NotNull @Override public Comparator getComparator() { return (o1, o2) -> { if (o1 instanceof Group && !(o2 instanceof Group)) return -1; if (!(o1 instanceof Group) && o2 instanceof Group) return 1; return 0; }; } @Override public boolean isVisible() { return true; } @Override @NotNull public ActionPresentation getPresentation() { throw new RuntimeException(); } @Override @NotNull public String getName() { throw new RuntimeException(); } }); myModel.addSorter(new Sorter() { @NotNull @Override public Comparator getComparator() { return Comparator.comparing(Object::toString); } @Override public boolean isVisible() { return true; } @Override @NotNull public ActionPresentation getPresentation() { throw new RuntimeException(); } @Override @NotNull public String getName() { throw new RuntimeException(); } }); assertStructureEqual(""" root .Group:a ..Group:d ...ade ....Group:a .....Group:d ......aed ..abc ...Group:a ....Group:d .....abc_de .Group:b ..Group:d ...bcd ....Group:b .....bhg_yt ..Group:f ...bft ....ttt .Group:d ..eed ...zzz .xxx .xxx ..Group:a ...aaa ....Group:b .....bbb """, null); }