2724. Sort By
\n# Code\njavascript []\n\nvar sortBy = function (arr, fn) {\n    return arr.sort((a, b) => fn(a) - fn(b));\n};\n\n
\n# Code\n```javascript []\n\nvar sortBy = function (arr, fn) {\n    return arr.sort((a, b) => fn(a) - fn(b));\n};\n\n```
['JavaScript']