Beats 84.66% of users with JavaScript
\n\n# Code\n\n/**\n * @param {Array} arr\n * @param {Function} fn\n * @return {Array}\n */\nvar sortBy = function(arr, fn) {\n    return arr.sort((a, b) => fn(a
\n\n# Code\n```\n/**\n * @param {Array} arr\n * @param {Function} fn\n * @return {Array}\n */\nvar sortBy = function(arr, fn) {\n    return arr.sort((a, b) => fn(a) - fn(b));\n};\n\n```
['JavaScript']