Skip to content
Advertisement

Reorder a tree node according to specific attribute in python

The code of simple tree

JavaScript

the code diagram is :given

I want a function or a method that order the node according saveable attribute. I want the output like:

JavaScript

and so on

if we plot the output is same like: required

Advertisement

Answer

While I disagree with the approach, this is what you need to do: (I’ve modified the code as little as possible, and added tests at the bottom to prove it works)

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement