稳定的合并排序。
Name | Type | Description |
---|---|---|
array |
Array | 要排序的数组。 |
comparator |
mergeSort~Comparator | 用于比较数组中元素的函数。 |
userDefinedObject |
* | optional
作为第三个参数传递给comparator 的任何项。 |
Example:
// Assume array contains BoundingSpheres in world coordinates.
// Sort them in ascending order of distance from the camera.
var position = camera.positionWC;
Cesium.mergeSort(array, function(a, b, position) {
return Cesium.BoundingSphere.distanceSquaredTo(b, position) - Cesium.BoundingSphere.distanceSquaredTo(a, position);
}, position);
Type Definitions
在执行合并排序时用来比较两个项目的函数。
Name | Type | Description |
---|---|---|
a |
* | 数组中的项。 |
b |
* | 数组中的项。 |
userDefinedObject |
* | optional
传递给mergeSort 的对象。 |
Returns:
如果a小于
b
,则返回a
nega
ctive va
lue,
如果a大于b
,则为正值,或
如果a等于b
,则为0。Example:
function compareNumbers(a, b, userDefinedObject) {
return a - b;
}