treelib icon indicating copy to clipboard operation
treelib copied to clipboard

Disable sorting per default

Open villmow opened this issue 6 years ago • 1 comments

Problem: If you call str(tree), it is sorted per default. There is no way of obtaining an unsorted string representation of a tree. The __print_backend function is private and can't be called from outside.

The problem is the the sorting parameter in expand_tree(), which is called by many functions, that don't pass the parameters to expand_tree (to_graphviz, leaves, subtree).

Furthermore the interface to sorting is really messed up (the name of the parameter):

  • If you want to iter a tree unsorted you have to call expand_tree(sorting=False).
  • You can print a tree unsorted, by calling tree.show(key=False),
  • If you want to convert a tree to a dictionary, you need to call to_dict(sort=True)

villmow avatar Mar 18 '19 08:03 villmow

I upvote that sorting should be disabled by default. I had a hard time trying to obtain an unsorted tree.show()

erhant avatar Dec 17 '20 21:12 erhant