JavaScript Solution
\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/**\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']