mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-06 15:03:08 -05:00
20 lines
710 B
TypeScript
20 lines
710 B
TypeScript
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 === 'indextsx') return -1;
|
|
if (b.fileKey === 'indextsx') 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;
|
|
});
|
|
}
|