Order of groups returned by findTopLevelGroups


We are using a modified version of the LaneLayout sample which generally works great. However with one of our diagrams, the order of the lanes isn’t what we’d expect but only in Chrome, it’s working as expected in FireFox and IE. The last lane is shown as the first lane. The order the lanes are added to the model is correct but our call to findTopLevelGroups returns the last lane as the first lane. Is the order of groups returned by findTopLevelGroups expected to match the order they were added to the model?

The order of Groups in the findTopLevelGroups() iterator is undefined – you cannot depend on the ordering. Even if what you say were true now, it might not be true in the future.

Aren’t you sorting the Groups in the Diagram.layout? You’ll need to make sure you specify the ordering that you want when the comparer function is given two “equal” objects.

Thanks. Sorting the groups in doLayout fixed the issue. We altered the LaneLayout sample so it doesn’t inherit from GridLayout anymore so we don’t have a comparer function. IIRC the reason for that is we have some top-level objects that aren’t in lanes and inheriting from GridLayout caused them to get laid out in a grid as well