g2701_2800.s2724_sort_by.solution.ts Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java Show documentation
Show all versions of leetcode-in-java Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
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