MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / sortIdsByNode

Function sortIdsByNode

frontend/app/treeview/treeview.tsx:91–107  ·  view source on GitHub ↗
(nodesById: Map<string, TreeNodeData>, ids: string[])

Source from the content-addressed store, hash-verified

89}
90
91function sortIdsByNode(nodesById: Map<string, TreeNodeData>, ids: string[]): string[] {
92 return [...ids].sort((leftId, rightId) => {
93 const left = nodesById.get(leftId);
94 const right = nodesById.get(rightId);
95 const leftDir = left?.isDirectory ? 0 : 1;
96 const rightDir = right?.isDirectory ? 0 : 1;
97 if (leftDir !== rightDir) {
98 return leftDir - rightDir;
99 }
100 const leftLabel = normalizeLabel(left ?? { id: leftId, isDirectory: false }).toLocaleLowerCase();
101 const rightLabel = normalizeLabel(right ?? { id: rightId, isDirectory: false }).toLocaleLowerCase();
102 if (leftLabel !== rightLabel) {
103 return leftLabel.localeCompare(rightLabel);
104 }
105 return leftId.localeCompare(rightId);
106 });
107}
108
109export function buildVisibleRows(
110 nodesById: Map<string, TreeNodeData>,

Callers 3

appendNodeFunction · 0.85
buildVisibleRowsFunction · 0.85
loadChildrenFunction · 0.85

Calls 2

normalizeLabelFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected