You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
563 B
JavaScript

'use strict';
const naturalSort = require("natural-sort");
const rfr = require("rfr");
const priorityRules = rfr("lib/sorting/priority-rules");
module.exports = function() {
let naturalSorter = naturalSort();
let ruleSorter = priorityRules([
function(entry) {
return entry.name === "..";
},
function(entry) {
return entry.targetType === "folder";
}
]);
return function(entryA, entryB) {
let result = ruleSorter(entryA, entryB);
if (result !== 0) {
return result;
} else {
return naturalSorter(entryA.name, entryB.name);
}
}
}