Always pass on a compare function to sort
This commit is contained in:
@@ -37,6 +37,18 @@ ol.array.binaryFindNearest = function(arr, target) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Default compare for array sort, will make sure number sort works okay.
|
||||
* @param {*} a The first object to be compared.
|
||||
* @param {*} b The second object to be compared.
|
||||
* @return {number} A negative number, zero, or a positive number as the first
|
||||
* argument is less than, equal to, or greater than the second.
|
||||
*/
|
||||
ol.array.defaultCompare = function(a, b) {
|
||||
return a > b ? 1 : a < b ? -1 : 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Whether the array contains the given object.
|
||||
* @param {Array.<*>} arr The array to test for the presence of the element.
|
||||
|
||||
Reference in New Issue
Block a user