(node: Node)
| 292 | } |
| 293 | |
| 294 | function sort(node: Node) { |
| 295 | node.children.sort((a, b) => { |
| 296 | if (!a.children.length && b.children.length) return 1 |
| 297 | if (!b.children.length && a.children.length) return -1 |
| 298 | return a.path.at(-1)!.localeCompare(b.path.at(-1)!) |
| 299 | }) |
| 300 | for (const child of node.children) { |
| 301 | sort(child) |
| 302 | } |
| 303 | } |
| 304 | sort(root) |
| 305 | |
| 306 | let current = [root] |