MCPcopy Create free account
hub / github.com/antonmedv/gitmal / sortNode

Function sortNode

commit.go:319–335  ·  view source on GitHub ↗
(n *templates.FileTree)

Source from the content-addressed store, hash-verified

317}
318
319func sortNode(n *templates.FileTree) {
320 if len(n.Children) == 0 {
321 return
322 }
323 sort.Slice(n.Children, func(i, j int) bool {
324 a, b := n.Children[i], n.Children[j]
325 if a.IsDir != b.IsDir {
326 return a.IsDir && !b.IsDir // dirs first
327 }
328 return strings.ToLower(a.Name) < strings.ToLower(b.Name)
329 })
330 for _, ch := range n.Children {
331 if ch.IsDir {
332 sortNode(ch)
333 }
334 }
335}

Callers 1

buildFileTreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected