sort by - solution in Quick Sort
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {Array} arr\n * @param {Function} fn\n * @return {Array}\n */\nvar sortBy = function (arr, fn) {\n    if (arr.length <= 1) {\n        return arr;\n    }\n\n    let pivot = arr[0];\n    let leftArr = [];\n    let rightArr = [];\n\n    for (let i = 1; i < arr.length; i++) {\n\n        if(fn(arr[i]) < fn(pivot)) {\n            leftArr.push(arr[i])\n        } else {\n            rightArr.push(arr[i]);\n        }\n    }\n\n    return [...sortBy(leftArr, fn), pivot, ...sortBy(rightArr, fn)]\n};\n```
['JavaScript']