UNPKG

@stryke/helpers

Version:

A package containing miscellaneous helper functions that are used across many different Storm Software projects.

18 lines (17 loc) 464 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getOrderedBy = getOrderedBy; function getOrderedBy(f, n, o) { const u = (r, e, t) => r < e ? t === "asc" ? -1 : 1 : r > e ? t === "asc" ? 1 : -1 : 0, T = n.map((r, e) => o[e] ?? o.at(-1)); return [...f].sort((r, e) => { for (const [t, c] of n.entries()) { const i = T[t], s = u(r[c], e[c], i); if (s !== 0) return s; } return 0; }); }