Sorting of array , working behind scence?

Tell us what’s happening:

How does my random arr is sorted when it is passed to random.sort((a,b)=>a-b)
Can anyone tell me stepwise ?

Your code so far

function getIndexToIns(arr, num) {
// Find my place in this sorted array.
return num;

getIndexToIns([40, 60], 50);

let random = [12,14,1,10,8];

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Where do I Belong

Link to the challenge:

no, it depends on how it is implemented, it uses one of many possible sort algorithms

1 Like