Very easy and simple solution in JS :)
\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# 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```
['JavaScript']