1. vector and binary predicates

Or rather not using binary predicates...

I'm probably missing something really simple here, but I can't see what I am doing wrong.

When using the STL vector template you can use the algorithm sort (defined in <algorithm>) to sort the vector. There are two versions available, one that takes a binary predicate as an argument and one that does not.

Now if you don't supply the binary predicate, the algorithm will attempt to sort using the < operator if it is defined which works fine if you have a vector of objects. BUT - if I have a vector of pointers to objects, it wont sort, in fact the operator< method is never called.
Code:
```	bool operator<(const CFoo &f)
{
if (data < f.data)
return true;
else
return false;
}```
Now the above code works a treat for a vector declared as vector<CFoo> vec;

But if I have a vector declared as vector<CFoo *> vec; I can't seem to rewrite the operator. For a binary predicate it is simply a case of changing the predicate to a dereferencing predicate, but it doesn't appear to be case here as below...
Code:
```bool operator<(const CFoo *f)
{
if (data < f->data)
return true;
else
return false;
}```
Any really obvious mistakes pointed out are appreciated!

2. Code:
```bool MySort(const CFoo* foo1, const CFoo* foo2)
{
return foo1->data < foo2->data;
}
...
vector<CFoo*> vec;
...
sort(vec.begin(),vec.end(),MySort);```

3. Sorry, might not have made myself clear ( I do ramble) - thanks for your response though..

I know how to do this with a dereferencing binary predicate, I was wondering though if it is possible to have the object be responsible for determining whether it should be sorted (i.e. using the operator< method).

Using the operator< method works fine if you are using references, but the second you use pointers a dereferencing operator< method does not seem to work, probably due to an error of mine, but I can't see the error.

4. Code:
```class CFoo
{
int data;
public:
bool operator<(const CFoo *f)
{
if (data < f->data)
return true;
else
return false;
}
};
...
vector<CFoo*> vec;
...
sort(vec.begin(),vec.end());```
As defined, you cannot have the above less-than operator used in the sort function, I'm not sure it would even ever make any sense to have something like that. The container stores pointers to objects and the comparison needs to be geared towards that... comparing pointers-to-objects with other pointers-to-objects. What you seem to be trying to do with the above operator is comparing objects with pointers-to-objects which won't work.

I guess the above operator could be used in the following manner but it seems odd to have a real need for it:
Code:
```CFoo  foo1;
CFoo  foo2;
CFoo* foo2ptr = &foo2;
...
if( foo1 < foo2ptr )  // Seems an odd/uncommon usage here
{
// Do stuff
}```
[/edit]