✅ ✅ Simple TypeScript Solution with explanation ✅ ✅
\nWe have to return sorted array, so we simply use arrays method sort. But the values, that has to be sorted dependent on function "fn" from arguments. Because 
\nWe have to return sorted array, so we simply use arrays method sort. But the values, that has to be sorted dependent on function "fn" from arguments. Because of that we have to run function inner and pass arguments "a" and "b". The functions return us values that we have to compare. So we do it and return result.\n\n# Code\n```\ntype JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue };\ntype Fn = (value: JSONValue) => number\n\nfunction sortBy(arr: JSONValue[], fn: Fn): JSONValue[] {\n   return arr.sort((a, b) => fn(a) - fn(b)); \n};\n```
['TypeScript']