Skip to content

Commit 5bf7aa3

Browse files
committed
Sort the package treelist items alphabetically by name.
1 parent 46f54e5 commit 5bf7aa3

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

codepulse/src/main/resources/toserve/pages/traces/PackageController.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,20 @@
124124
}
125125
}
126126

127-
;(node.children || []).forEach(function(kid){
128-
var nextParent = (node.kind == 'group' || node.kind == 'package')? node : packageParentNode
129-
setupTreeHierarchy(nextParent, kid)
130-
})
127+
;(node.children || [])
128+
.sort(function(a,b){
129+
// alphabetic sort by node.name
130+
var an = a.name.toUpperCase(),
131+
bn = b.name.toUpperCase()
132+
133+
if(an < bn) return -1
134+
if(an > bn) return 1
135+
return 0
136+
})
137+
.forEach(function(kid){
138+
var nextParent = (node.kind == 'group' || node.kind == 'package')? node : packageParentNode
139+
setupTreeHierarchy(nextParent, kid)
140+
})
131141

132142
})(undefined, treeData.root)
133143

0 commit comments

Comments
 (0)