refactor: sort-files -> common utils

This commit is contained in:
Oliver Eyton-Williams
2020-06-05 18:00:05 +02:00
committed by Mrugesh Mohapatra
parent 063145fe90
commit 88de5bc602
4 changed files with 4 additions and 5 deletions

15
utils/sort-files.js Normal file
View File

@@ -0,0 +1,15 @@
exports.sortFiles = function sortFiles(challengeFiles) {
const xs = Object.values(challengeFiles);
// TODO: refactor this to use an ext array ['html', 'js', 'css'] and loop over
// that.
xs.sort((a, b) => {
if (a.ext === 'html') return -1;
if (b.ext === 'html') return 1;
if (a.ext === 'jsx') return -1;
if (b.ext === 'jsx') return 1;
if (a.ext === 'js') return -1;
if (b.ext === 'js') return 1;
return 0;
});
return xs;
};