*
* @param node Node instance whose children to be sorted
* @param comparator Comparator to use in sorting
*/
public static void sortNode(TreeNode node, Comparator comparator) {
TreeNodeChildren children = (TreeNodeChildren) node.getChildren();
if(children != null && !children.isEmpty()) {
Object[] childrenArray = children.toArray();
Arrays.sort(childrenArray, comparator);
for(int i = 0; i < childrenArray.length; i++) {
children.setSibling(i, (TreeNode) childrenArray[i]);
}
for(int i = 0; i < children.size(); i++) {
sortNode(children.get(i), comparator);
}
}
}