Need to sort the nodes by their level .
For example green node belongs to one level and orange one belongs to one level.but…its mixed in position after sorting(see above pic)
The sorting in TreeLayout only applies to the immediate children of a vertex. Are you asking about how to order the nodes in a layer when the nodes do not share the same parent but only share a grandparent or a greatgrandparent?
If so, I suppose you could override TreeLayout.commitNodes to call the super method and then rearrange the nodes the way that you want. But that might cause problems if the nodes are of different sizes.