See specs on
array.sort()
That sort function should have two object parameters (a,b below) which (I assume) just get "magically"* passed to that function by the .sort function.
As touched on already, array.sort() accepts an optional parameter in the form of a function reference (lets call it sortfunction). The format of this function looks like this:
array.sort(sortfunction)
function sortfunction(a, b){
//Compare "a" and "b" in some fashion, and return -1, 0, or 1
}
* I'm new to .
js And:
Any sufficiently advanced technology is indistinguishable from magic.