MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / sortChallengeFiles

Function sortChallengeFiles

client/utils/sort-challengefiles.ts:1–21  ·  view source on GitHub ↗
(
  challengeFiles: File[]
)

Source from the content-addressed store, hash-verified

1export function sortChallengeFiles<File extends { fileKey: string }>(
2 challengeFiles: File[]
3): File[] {
4 return challengeFiles.toSorted((a, b) => {
5 if (a.fileKey === 'indexjsx') return -1;
6 if (b.fileKey === 'indexjsx') return 1;
7 if (a.fileKey === 'indextsx') return -1;
8 if (b.fileKey === 'indextsx') return 1;
9 if (a.fileKey === 'indexhtml') return -1;
10 if (b.fileKey === 'indexhtml') return 1;
11 if (a.fileKey === 'stylescss') return -1;
12 if (b.fileKey === 'stylescss') return 1;
13 if (a.fileKey === 'scriptjs') return -1;
14 if (b.fileKey === 'scriptjs') return 1;
15 if (a.fileKey === 'indexts') return -1;
16 if (b.fileKey === 'indexts') return 1;
17 if (a.fileKey === 'tsconfigjson') return -1;
18 if (b.fileKey === 'tsconfigjson') return 1;
19 return 0;
20 });
21}

Callers 3

getTargetEditorFunction · 0.90
renderMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected