- // allocate an array for the wxObject pointers of the list
- const size_t num = Number();
- wxObject **objArray = new wxObject *[num];
- wxObject **objPtr = objArray;
-
- // go through the list and put the pointers into the array
- wxNode *node = First();
- while(node!=NULL){
- *objPtr++ = node->Data();
- node = node->Next();
- }
- // sort the array
- qsort((void *)objArray,num,sizeof(wxObject *),compfunc);
- // put the sorted pointers back into the list
- objPtr = objArray;
- node = First();
- while(node!=NULL){
- node->SetData(*objPtr++);
- node = node->Next();
- }
- // free the array
- delete[] objArray;
+ // allocate an array for the wxObject pointers of the list
+ const size_t num = GetCount();
+ void **objArray = new void *[num];
+ void **objPtr = objArray;
+
+ // go through the list and put the pointers into the array
+ wxNodeBase *node;
+ for ( node = GetFirst(); node; node = node->Next() )
+ {
+ *objPtr++ = node->Data();
+ }
+
+ // sort the array
+ qsort((void *)objArray,num,sizeof(wxObject *),compfunc);
+
+ // put the sorted pointers back into the list
+ objPtr = objArray;
+ for ( node = GetFirst(); node; node = node->Next() )
+ {
+ node->SetData(*objPtr++);
+ }
+
+ // free the array
+ delete[] objArray;