I have an organization chart diagram with too much units ( about 200 )
When i use auto layouting or tree style layout from Diagram -> Layout menu, it will overlap the lines of some nodes on other lines and also on some units.
I have shown this problem in the attached image.
Image 1 : Diagram with auto layout
Image2 : Diagram with manual sorting
I guess your sorting algorithm needs a few changes in cases diagram has too much nodes ( like when we have too many units in an organization chart diagram )