Closed pysan3 closed 7 months ago
You can get the current nodes using tree:get_nodes
, sort it, and then set the sorted nodes using tree:set_nodes
.
I see but that runs initialize_nodes
which runs a recursion thru children, which is kind of inefficient IMO.
I just want to rearrange the children of a single node in (or not in) a tree.
As sorting does not change or modify any node, tree.nodes.by_id
does not need to change if I'm not mistaken.
Would be nice if we can optimize the current methods instead of adding a new one. I'm very hesitatnt on adding new methods... the philosophy of nui.nvim
always has been to provide very general minimal APIs so that users can build on top of that.
OK, yes I now started to think I should implement an application specific sorter anyways so that it can be more optimized than a general API from nui.
Thanks for your opinions. Closing!
Hi, thanks again for the awesome library.
Is there a way to sort node children?
I'd imagine an API similar to
table.sort
but I couldn't find anything.