An electron-based WIP aesthetic file explorer ^^
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FileKade/scripts/fileview/load/sort.js

27 lines
875 B

module.exports = (mode, check=false) => {
3 years ago
mode = mode || window.kade.sort;
let ts = check ? window.kade.chdir : window.kade.cdir;
3 years ago
switch (mode) {
case 'Name':
ts.sort((a, b) => {
3 years ago
a = a.name.toLowerCase();
b = b.name.toLowerCase();
return a > b ? 1 : a < b ? -1 : 0;
});
break;
case 'Date':
ts.sort((a, b) => a.lastModified - b.lastModified);
3 years ago
break;
case 'Type':
ts.sort((a, b) => {
3 years ago
a = a.type.toLowerCase();
b = b.type.toLowerCase();
return a > b ? 1 : a < b ? -1 : 0;
});
break;
case 'Size':
ts.sort((a, b) => a.size - b.size);
3 years ago
break;
}
if (!window.kade.ascend) {ts.reverse();}
3 years ago
};