tags:

views:

85

answers:

1

As you might have already guessed I don't want to sort the pointer addresses but the objects/data.

At the moment I have an array like this:

CArray <ReadObject *> readCollecion; 

and I sort it like that:

std::sort(readCollecion.GetData(), readCollecion.GetData()+readCollecion.GetSize(), keySortFunction);

Works perfectly with the keySortFunction.

The problem is I need pointers to my objects because I need to modify the objects while they are already in the array. I guess I need and Array like this:

CArray <ReadObject *> readCollecion; 

Now I can change the objects afterwards but my sort seems to be unable to deal with this.

A: 

If I'm understanding your question correctly, all you need to do is change the parameter type of keySortFunction from const ReadObject& to const ReadObject* and make the appropriate changes to the function to use -> instead of .

Mark B