How can I get edges related info in Treelayout Comparer method?

I wrote the following comparer method.

function getLayout($, go) {
return $(go.TreeLayout, {
angle: 90,
nodeSpacing: 100,
layerSpacing: 120,
sorting: go.TreeLayout.SortingAscending,
comparer: function(va, vb) {

        var da =;
        var db =;

        console.log("edge data",va.edges); // doesn't contain any required info about edges, why?

       // sorts based on node order value. We want to sort based on edges.order but it doesn't work.
        if (da.key < db.order) return -1;
        if (da.key > db.order) return 1;
        return 0;


I want to sort nodes by order value of it’s edge ( from parent).
va.edges // this doesn’t contain any edge related info apart from count. It has a iterator but that too doesn’t contain anything that I need. comes out undefined.

How can I sort nodes based on edges.order, i.e how can I get edge related info at comparer method.

Or is there any other way of doing this, apart from using comparer method.

This is what my sample diagramJson looks like:

“nodes” : [ {
“key” : “fb016268-39d5-42d4-a3b5-77caa75695cb”,
“node_id” : “177477dc435711102213698f38b8f2df”,
“name” : “Start Node”,
“order”: 10
“key” : “fb016268-39d5-42d4-a3b5-77caa75695cc”,
“node_id” : “177477dc435711102213698f38b8f2df”,
“name” : “Decision Node”,
“order”: 20
“key” : “fb016268-39d5-42d4-a3b5-77caa75695cd”,
“node_id” : “5da43bdc435711102213698f38b8f22e”,
“name” : “Guidance Node”,
“order”: 10
“edges” : [ {
“from”: “fb016268-39d5-42d4-a3b5-77caa75695cb”,
“fromPort”: “1b58864543031110f5a404836ab8f209”,
“to”: “fb016268-39d5-42d4-a3b5-77caa75695cd”,
“order”: 200,
“toPort”: “0fdf576e251c2110f8778c1b14420cdb”,
“edge_id”: “cce4fbdc435711102213698f38b8f27d”
“from”: “fb016268-39d5-42d4-a3b5-77caa75695cb”,
“fromPort”: “1b58864543031110f5a404836ab8f209”,
“to”: “fb016268-39d5-42d4-a3b5-77caa75695cc”,
“order”: 100,
“toPort”: “615c13aa251c2110f8778c1b14420c62”,
“edge_id”: “cce4fbdc435711102213698f38b8f27d”
“node_arguments” : [ ],
“variables” : [ ],
“edge_arguments” : [ ]

Yes, the arguments to the TreeLayout.comparer are child TreeVertexes.

The value of TreeVertex.edges is documented:

This read-only property returns an iterator for all of the edges that are connected with this vertex in either direction.
Note that this is inefficient compared to iterating over the edges: sourceEdges and destinationEdges.

So the collection would include edges connecting the child to grandchildren.

I would use something like:

  (va, vb) => {
    const ea = va.sourceEdges.first();
    const eb = vb.sourceEdges.first();
    if (!ea || !eb) return 0;
    return -;

This code assumes that your LayoutNetwork has no dummy TreeEdges, that there are no unmodeled Links, that there is a GraphLinksModel, and that every link data object has an “order” property that has a real number value.

The solution is working. Thanks for the quick response.