//
// GJBaseGameLayer::sortGroups from 0x1001dfda0 to 0x1001dfee4 (324 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::updateSpecialGroupData @ 0x1001dfbdc
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void __fastcall GJBaseGameLayer::sortGroups(GJBaseGameLayer *a1)
{
LevelSettingsObject *m_levelSettings; // x8
bool m_sortGroups; // w20
cocos2d::CCArray *m_objects; // x8
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **arr; // x21
unsigned __int64 v8; // x22
cocos2d::CCObject *v9; // x8
unsigned int m_uReference; // w9
__int64 *i; // x22
cocos2d::CCArray *Group; // x21
cocos2d::CCObject *v13; // [xsp+8h] [xbp-68h] BYREF
__int128 v14; // [xsp+10h] [xbp-60h] BYREF
__int128 v15; // [xsp+20h] [xbp-50h]
int v16; // [xsp+30h] [xbp-40h]
v14 = 0u;
v15 = 0u;
v16 = 1065353216;
m_levelSettings = a1->m_levelSettings;
if ( m_levelSettings )
m_sortGroups = m_levelSettings->m_sortGroups;
else
m_sortGroups = 0;
m_objects = a1->m_objects;
if ( m_objects )
{
data = m_objects->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v8 = (unsigned __int64)&arr[num - 1];
do
{
v9 = *arr;
if ( !*arr )
break;
m_uReference = v9[18].m_uReference;
if ( m_uReference == 3607 )
{
if ( !a1->m_isEditor )
{
v13 = *arr;
sub_1000115B8((__int64)&a1->m_sequenceTriggers, &v13);
}
}
else if ( m_uReference == 1268 && !m_sortGroups )
{
LODWORD(v13) = v9[26].m_uID;
sub_10001C1B0((unsigned __int64)&v14, (int *)&v13, &v13);
}
++arr;
}
while ( (unsigned __int64)arr <= v8 );
}
}
if ( m_sortGroups )
{
GJBaseGameLayer::sortAllGroupsX(a1);
}
else
{
for ( i = (__int64 *)v15; i; i = (__int64 *)*i )
{
Group = GJBaseGameLayer::getGroup(a1, *((_DWORD *)i + 4));
if ( (unsigned int)sub_10024A36C(Group) >= 2 )
qsort(Group->data->arr, Group->data->num, 8u, (int (__cdecl *)(const void *, const void *))sub_1001D9B84);
}
}
sub_100017A98((__int64)&v14);
}