I was wondering how the javascript Array sort method works when a custom sort function is specified as shown below:
arr = [1, 5, 122, 12]; arr.sort(function (a,b){return ab;});
if it takes only two arguments a, b (1,5) in "arr", I know that javascript allows more arguments than those specified in the function. but how does the sort function work, does it compare 1.5, then 122.12, save the result in place, then repeat the comparison.
source share