Where do I belong - Reduce method

Tell us what’s happening:
I am using reduce function here, But I don’t know why… certain cases fail.

Your code so far

function getIndexToIns(arr, num) {
  arr.push(num);
arr.sort().reduce(function (curr,prev){
  return curr - prev;
});
return arr.indexOf(num);
}

getIndexToIns([40, 60], 50);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/where-do-i-belong

Ahh, Thank you so much @camperextraordinaire, I found the mistake and correct that, Here my code :grinning:

function getIndexToIns(arr, num) {
  arr.push(num);
  arr.sort(function (a,b){
    return a -b 
  });               // sort function
  console.log(arr); // display arr after sort but before reduce is implemented  
  arr.reduce(function (curr,prev){
    return curr - prev;
  });
  return arr.indexOf(num);
}
getIndexToIns([3, 10, 5], 3); // returns 1 instead of 0