MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / sortNodes

Function sortNodes

website/src/components/PRReviewer.tsx:225–232  ·  view source on GitHub ↗
(nodes: TreeNode[])

Source from the content-addressed store, hash-verified

223
224 // Sort: folders first, then files, each alphabetically
225 const sortNodes = (nodes: TreeNode[]): TreeNode[] =>
226 nodes
227 .sort((a, b) => {
228 if (a.isDir && !b.isDir) return -1;
229 if (!a.isDir && b.isDir) return 1;
230 return a.name.localeCompare(b.name);
231 })
232 .map(n => ({ ...n, children: sortNodes(n.children) }));
233
234 return sortNodes(root);
235}

Callers 1

buildTreeFunction · 0.70

Calls 1

mapMethod · 0.65

Tested by

no test coverage detected