# mergeSort

engine/Source/Core/mergeSort.js 55
A stable merge sort.

##### Example:

    // Assume array contains BoundingSpheres in world coordinates.
    // Sort them in ascending order of distance from the camera.
    const position = camera.positionWC;
    Cesium.mergeSort(array, function(a, b, position) {
        return Cesium.BoundingSphere.distanceSquaredTo(b, position) - Cesium.BoundingSphere.distanceSquaredTo(a, position);
    }, position);

Need help? The fastest way to get answers is from the community and team on the Cesium Forum.