Skip to main content
cngx-src documentation

sortTree

Functionutils/tree

projects/utils/tree.ts

Description#

Return a new tree where each level's siblings are sorted independently by the by extractor. Child ordering is stable within its own level only - the relative position of nodes across different parents is irrelevant.

The treetable keeps its own numeric-aware localeCompare collation - this comparator (< / > on the extractor output) is not a drop-in replacement for it.

Signature#

sortTree(nodes, by, direction)

Parameters#

@paramnodes
@paramby
@paramdirection= 'asc'

Returns#

CngxTreeNode[]