How to Sort the rendering of nodes in consistent way?

Hello,
I am newbie and using GoJs. I have nodes, groups and links. When I load the page, I sometimes get Render 1 and other times I get Render 2. I was playing around with sorting properties but it is not working as expected.

This is what I looked at:

  1. Do you know how is this order determined?
  2. How can I control such that it is consistent render of the nodes in my UI ?

Here is my snippet:

diagram.groupTemplate.layout = $(go.GridLayout,
{
wrappingColumn: 1,
sorting: go.GridLayout.Ascending
}

var diagram =
$(go.Diagram, “diagram-div”, {
autoScale: go.Diagram.Uniform,
contentAlignment: go.Spot.TopLeft,
“toolManager.hoverDelay”: 10,
layout: $(go.LayeredDigraphLayout,
{
aggressiveOption: go.LayeredDigraphLayout.AggressiveMore,
setsPortSpots: false,
isOngoing: false
})
});

LayeredDigraphLayout is supposed to re-order the nodes in a layer in order to reduce the number of link crossings. When the graph is tree-structured (or close to it) you can use TreeLayout if you want to order the children of each node.

For both TreeLayout and GridLayout you need to make sure to either supply a comparer function or else data bind the Node.text property so that it will sort based on data that you control.

Thanks Walter.
Is there a way to order the nodes LayeredDigraphLayout instead of using Tree or GridLayout ?
I like the render of LayeredDigraphLayout much better then tree and moreover my graph is not a tree, Thx

Not really, sorry.