diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 5bfdb27181..7d93075de3 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -1140,7 +1140,7 @@ void Node::sortAllChildren() { if (_reorderChildDirty) { - std::sort(std::begin(_children), std::end(_children), nodeComparisonLess); + std::stable_sort(std::begin(_children), std::end(_children), nodeComparisonLess); _reorderChildDirty = false; } } diff --git a/cocos/2d/CCProtectedNode.cpp b/cocos/2d/CCProtectedNode.cpp index dc20590012..a265ec2456 100644 --- a/cocos/2d/CCProtectedNode.cpp +++ b/cocos/2d/CCProtectedNode.cpp @@ -252,7 +252,7 @@ void ProtectedNode::insertProtectedChild(cocos2d::Node *child, int z) void ProtectedNode::sortAllProtectedChildren() { if( _reorderProtectedChildDirty ) { - std::sort( std::begin(_protectedChildren), std::end(_protectedChildren), nodeComparisonLess ); + std::stable_sort( std::begin(_protectedChildren), std::end(_protectedChildren), nodeComparisonLess ); _reorderProtectedChildDirty = false; } }