Returns comparator function.
nullvar cmp = format.comparator(values, greater, less, equal, error);
values (array) - array of values to compare
greater (number) - +1
or -1
depending on the sort direction
less (number) - -1
or +1
depending on the sort direction
equal (function) - to be callled if the values are equal
error (function) - to be called if there is an error
comparator function to be used in array.sort(function)
format.comparator = function(values, greater, less, equal, error){
return function(i, j){
try {
var a = values[i];
var b = values[j];
if (a > b) {return greater}
if (a < b) {return less}
return equal(i, j);
}
catch(e){
return error(i, j, e);
}
}
};
Grid control: sort method