Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 5x 11x 4x 10x 6x 11x | import {KeyProjection} from 'fnxt/fnxt-types'; /** * @deprecated use sortWith * @param fn */ export const sortByDescending = <T>(fn: KeyProjection<T>) => (array: T[]): T[] => { const tuples = array.map(e => [fn(e), e]); return (tuples // @ts-ignore .sort((tuples[0] && typeof tuples[0][0] === 'number') ? ((a: [number, T], b: [number, T]) => b[0] - a[0]) : ((a: [string, T], b: [string, T]) => b[0].localeCompare(a[0])) ) as [number, T][] | [string, T][]) .map((e: [number | string, T]) => e[1]) as T[]; }; |