my-idlers/node_modules/collect.js/dist/methods/sort.js
cp6 fd22b0bf58 V2 (Laravel re-make)
V2 (Laravel re-make)
2022-03-06 02:02:12 +11:00

21 lines
409 B
JavaScript
Vendored

'use strict';
module.exports = function sort(fn) {
var collection = [].concat(this.items);
if (fn === undefined) {
if (this.every(function (item) {
return typeof item === 'number';
})) {
collection.sort(function (a, b) {
return a - b;
});
} else {
collection.sort();
}
} else {
collection.sort(fn);
}
return new this.constructor(collection);
};