caesar0301 / treelib

An efficient implementation of tree data structure in python 2/3.
http://treelib.readthedocs.io/en/latest/
Other
817 stars 188 forks source link

order problem #53

Closed shmilyoo closed 8 years ago

shmilyoo commented 8 years ago

now children display order is not according to the insert order but the node.tag order . is there any way to change the order parameter?

caesar0301 commented 8 years ago

This is possible, but it needs some modification to Node class and related functions. As suggested by @aronadaal in 83d64f7dae374c34f2ff43bae98eed579a61eaec, we use Dict to store node list for efficiency. The modification can be as following: 1) add an order var. to Node class to record the global insertion time, e.g., an increasing ID. 2) use this inner var. to sort children wherever they are returned.

I am not sure I will have time to add this feature and give sufficient tests of the library, because I have an urgent deadline for my phd dissertation in the coming month. If your needs are urgent, you can implement this feature freely and give me a PR. I appreciate that very much.

Xiaming

caesar0301 commented 8 years ago

60 Thansk Daniel!