Production grade TS
Code\n\nconst sortBy = <I>(arr: I[], fn: (item: I) => number): I[] => {\n    return arr.sort((a, b) => fn(a) - fn(b));\n};\n\n
# Code\n```\nconst sortBy = <I>(arr: I[], fn: (item: I) => number): I[] => {\n    return arr.sort((a, b) => fn(a) - fn(b));\n};\n\n```
['TypeScript']