Qick sort
Code\njavascript []\n\nvar sortBy = function (arr, fn) {\n  if (arr.length <= 1) {\n    return arr;\n  }\n   const pivot = arr[Math.floor(arr.length / 2)];\n   
# Code\n```javascript []\n\nvar sortBy = function (arr, fn) {\n  if (arr.length <= 1) {\n    return arr;\n  }\n   const pivot = arr[Math.floor(arr.length / 2)];\n   const left = [];\n   const right = [];\n\n\n   for(const o of arr) {\n     const num = fn(o);\n     const middle = fn(pivot);\n     if (num < middle) {\n       left.push(o)\n     } else if (num > middle) {\n       right.push(o)\n     }\n   }\n\n  return [...sortBy(left, fn), pivot, ...sortBy(right, fn)]\n};\n\n```
['JavaScript']