Sort By Solution.
IntuitionJust use sort method by subtracting fn(a) - fn(b)Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

Just use sort method by subtracting `fn(a) - fn(b)`


# Code
```javascript []
/**
 * @param {Array} arr
 * @param {Function} fn
 * @return {Array}
 */
var sortBy = function(arr, fn) {
    return arr.sort((a, b) => fn(a) - fn(b));
};
```
['JavaScript']