### Question:
TreeSorter { public static <DATATYPE, ITEMTYPE extends ITreeItem <DATATYPE, ITEMTYPE>> void sort (@Nonnull final IBasicTree <? extends DATATYPE, ITEMTYPE> aTree, @Nonnull final Comparator <? super DATATYPE> aValueComparator) { _sort (aTree, Comparator.comparing (IBasicTreeItem::getData, aValueComparator)); } private  TreeSorter(); static void sort(@Nonnull final IBasicTree <? extends DATATYPE, ITEMTYPE> aTree,
                                                                                       @Nonnull final Comparator <? super DATATYPE> aValueComparator); static void sort(@Nonnull final IBasicTree <DATATYPE, ITEMTYPE> aTree);  }### Answer:
@Test public void testTreeString () { final DefaultTree <String> aTree = new DefaultTree <> (); assertNotNull (aTree.getRootItem ()); final DefaultTreeItem <String> i1 = aTree.getRootItem ().createChildItem ("Windows"); i1.createChildItem ("sxs"); i1.createChildItem ("temp"); i1.createChildItem ("System32"); final DefaultTreeItem <String> i2 = aTree.getRootItem ().createChildItem ("Program Files"); i2.createChildItem ("Eclipse"); i2.createChildItem ("Apache Software Foundation"); TreeSorter.sort (aTree, IComparator.getComparatorCollating (Locale.US)); assertEquals (2, aTree.getRootItem ().getChildCount ()); final List <? extends DefaultTreeItem <String>> aChildren = aTree.getRootItem ().getAllChildren (); assertSame (i2, aChildren.get (0)); assertSame (i1, aChildren.get (1)); assertEquals (2, i2.getChildCount ()); assertEquals ("Apache Software Foundation", i2.getChildAtIndex (0).getData ()); assertEquals ("Eclipse", i2.getChildAtIndex (1).getData ()); assertEquals (3, i1.getChildCount ()); assertEquals ("sxs", i1.getChildAtIndex (0).getData ()); assertEquals ("System32", i1.getChildAtIndex (1).getData ()); assertEquals ("temp", i1.getChildAtIndex (2).getData ()); }
@Test public void testTreeNumeric () { final DefaultTree <BigDecimal> aTree = new DefaultTree <> (); final DefaultTreeItem <BigDecimal> i1 = aTree.getRootItem ().createChildItem (BigDecimal.valueOf (2)); i1.createChildItem (BigDecimal.valueOf (20)); i1.createChildItem (BigDecimal.valueOf (22)); i1.createChildItem (BigDecimal.valueOf (21)); final DefaultTreeItem <BigDecimal> i2 = aTree.getRootItem ().createChildItem (BigDecimal.valueOf (1)); i2.createChildItem (BigDecimal.valueOf (12)); i2.createChildItem (BigDecimal.valueOf (11)); TreeSorter.sort (aTree, Comparator.comparingInt (Number::intValue)); assertEquals (2, aTree.getRootItem ().getChildCount ()); final List <? extends DefaultTreeItem <BigDecimal>> aChildren = aTree.getRootItem ().getAllChildren (); assertSame (i2, aChildren.get (0)); assertSame (i1, aChildren.get (1)); assertEquals (2, i2.getChildCount ()); assertEquals (BigDecimal.valueOf (11), i2.getChildAtIndex (0).getData ()); assertEquals (BigDecimal.valueOf (12), i2.getChildAtIndex (1).getData ()); assertEquals (3, i1.getChildCount ()); assertEquals (BigDecimal.valueOf (20), i1.getChildAtIndex (0).getData ()); assertEquals (BigDecimal.valueOf (21), i1.getChildAtIndex (1).getData ()); assertEquals (BigDecimal.valueOf (22), i1.getChildAtIndex (2).getData ()); }