UNPKG

@stryke/helpers

Version:

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

2 lines (1 loc) 240 B
export 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})}