fd22b0bf58
V2 (Laravel re-make)
21 lines
409 B
JavaScript
Vendored
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);
|
|
}; |