sort method
Sorts the tree nodes based on the provided compare function.
If compareFunction
is null, the original order is restored.
Implementation
void sort(int Function(TreeNode<T>, TreeNode<T>)? compareFunction) {
setState(() {
if (compareFunction == null) {
_applySort(
_roots, (a, b) => a.originalIndex.compareTo(b.originalIndex));
} else {
_applySort(_roots, compareFunction);
}
});
}