All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g2701_2800.s2724_sort_by.solution.ts Maven / Gradle / Ivy

The newest version!
// #Easy #2023_09_19_Time_124_ms_(86.52%)_Space_57_MB_(53.08%)

type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue }
type Fn = (value: JSONValue) => number

const sortBy = (arr: JSONValue[], fn: Fn): JSONValue[] => [...arr].sort((a, b) => (fn(a) > fn(b) ? 1 : -1))

export { sortBy }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy