How does the following code sort this array to be in numerical order?
var array=[25, 8, 7, 41]
array.sort(function(a,b){
return a - b
})
var array=[25, 8, 7, 41]
array.sort(function(a,b){
console.log(`a = ${a} , b = ${b}`);
return a - b
});
OUTPUT
in my Browser (Google Chrome Version 70.0.3538.77 (Official Build) (64-bit) ) in the first iteration, the argument a is the Second element in an array and argument b is the First element of an array.
if the Compare function returns