refactor(client): simplify sort challenge files (#59179)

Co-authored-by: Naomi <accounts+github@nhcarrigan.com>
This commit is contained in:
Oliver Eyton-Williams
2025-04-02 20:50:43 +02:00
committed by GitHub
parent 6e1b87cc78
commit a82316e469
10 changed files with 64 additions and 94 deletions
+17
View File
@@ -0,0 +1,17 @@
export function sortChallengeFiles<File extends { fileKey: string }>(
challengeFiles: File[]
): File[] {
return challengeFiles.toSorted((a, b) => {
if (a.fileKey === 'indexjsx') return -1;
if (b.fileKey === 'indexjsx') return 1;
if (a.fileKey === 'indexhtml') return -1;
if (b.fileKey === 'indexhtml') return 1;
if (a.fileKey === 'stylescss') return -1;
if (b.fileKey === 'stylescss') return 1;
if (a.fileKey === 'scriptjs') return -1;
if (b.fileKey === 'scriptjs') return 1;
if (a.fileKey === 'indexts') return -1;
if (b.fileKey === 'indexts') return 1;
return 0;
});
}