If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Yes, your function is perfectly fine and legal. You may have problems with the this pointer however, since the sort function does not allow you to provide one when the object method is used from a pointer. You should change your sorting function to be a static member function if you want to use this approach, or you can use a global function.
Then, just call myArray.Sort(&AClass::sortSegments); if you are using a static member function, or myArray.Sort(sortSegments) if you are using a global function.
WX_DECLARE_OBJARRAY(class Foo, FooArray);
...
static int wxCMPFUNC_CONV StringCompareFunction(Foo **first, Foo **second)
{
return (*first)->GetString().CmpNoCase((*second)->GetString());
}
static int wxCMPFUNC_CONV IntCompareFunction(Foo **first, Foo **second)
{
return (*first)->Int > (*second)->Int;
}
// Usage:
FooArray array;
...
array.Sort( StringCompareFunction ); // Sort by string
// array.Sort( IntCompareFunction ); or by Int
Note that my wxArray is of objects, while yours is of pointers to objects (btw, is that allowed in WX_DECLARE_OBJARRAY? If you want pointers, why not use WX_DEFINE_ARRAY?)