Beats 98.06%of users with JavaScript
\n> ***var sortBy = function(arr, fn) {\n    return arr.sort((a,b) => fn(a) > fn(b) ? 1 : -1);};***\n
```\n> ***var sortBy = function(arr, fn) {\n    return arr.sort((a,b) => fn(a) > fn(b) ? 1 : -1);};***\n```
['JavaScript']