[Cocos2D-X] std::sort 이용해서 CCArray 정렬하는 방법
2015. 3. 26.
CCArray 안에 정수만 있다고 가정합니다. static bool compareIndex(const void* p1, const void* p2) { CCString* index1 = (CCString*)p1; CCString* index2 = (CCString*)p2; bool result = index1->intValue() intValue(); return result; } bool ViewerPartsAniEffectScene::sortByAscWithCCArray(CCArray* arr) { std::sort(arr->data->arr, arr->data->arr+arr->data->num, compareIndex); return true; }