(n *templates.FileTree)
| 317 | } |
| 318 | |
| 319 | func 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 | } |