sort method

void sort(
  1. int compareFunction(
    1. TreeNode<T>,
    2. TreeNode<T>
    )?
)

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);
    }
  });
}