Sorting arrays in JavaScript is done via the method array.sort().
Passing in a function reference into array.sort()
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:
[code]
array.sort(sortfunction)
function sortfunction(a, b){
//Compare "a" and "b" in some fashion, and return -1, 0, or 1
}
[/code]
When such a function is passed in...