Array.prototype.sortBy = function()

in src/shared/extension.ts [55:65]


Array.prototype.sortBy = function<T>(selector: Selector<T>, descending = false) {
    this.sort((a, b) => {
        const aa = selector(a);
        const bb = selector(b);
        const invert = descending ? -1 : 1;
        if (typeof aa === 'string' && typeof bb === 'string') return invert * aa.localeCompare(bb);
        if (typeof aa === 'number' && typeof bb === 'number') return invert * (aa - bb);
        return 0;
    });
    return this;
};