I have written a custom sorting routine (sortArray(a, b)
) to sort an array that I have.
If I call it like this
a.sort(function (v1, v2) { return sortArray(v1, v2); });
everything works fine.
If I call it like this:
a.sort(sortArray(v1, v2));
v1 and v2 raise errors, as being undefined.
Is there no way to utilize arguments passed by the .sort() method without creating an anonymous function to initially receive them, and then to pass them on to a user-defined function?