array.prototype.solution
IntuitionSince it was not limited to being able to use native js functions, thinking about doing the sorting "from scratch" seemed very complex, especially sinc
# Intuition
Since it was not limited to being able to use native js functions, thinking about doing the sorting "from scratch" seemed very complex, especially since the array could be made up of objects, numbers, strings, etc. So it was more intuitive to use the js sort method approach.

# Approach
solution using array.prototype.sort

# Complexity
- Time complexity:
O(nlogn)

- Space complexity:
O(n)

# Code
```typescript []
type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue };
type Fn = (value: JSONValue) => number

function sortBy(arr: JSONValue[], fn: Fn): JSONValue[] {
    return arr.sort((a :JSONValue, b :JSONValue) => fn(a)-fn(b))
};
```
['TypeScript']