(nodes: FileTreeNode[])
| 818 | |
| 819 | // Sort function for nodes |
| 820 | function sortNodes(nodes: FileTreeNode[]): void { |
| 821 | nodes.sort((a, b) => { |
| 822 | // Directories first, then files |
| 823 | if (a.type !== b.type) { |
| 824 | return a.type === 'directory' ? -1 : 1 |
| 825 | } |
| 826 | return a.name.localeCompare(b.name) |
| 827 | }) |
| 828 | |
| 829 | // Recursively sort children |
| 830 | for (const node of nodes) { |
| 831 | if (node.children) { |
| 832 | sortNodes(node.children) |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | |
| 837 | sortNodes(rootNodes) |
| 838 | return rootNodes |