How to use DefaultElementComparator


Hi all,

I'm having problems using the DefaultElementComparator. I'm not able to make the code to call the operator<(). Here is how I add a sorted Task

DefaultElementComparator<const Task*> sorter;

int index = _tasks.addSorted(sorter, task);

_task is a OwnedArray. When I want override the operator I do like this:


 friend bool operator<(const Task& task1, const Task& task2);


bool operator<(const Task& task1, const Task& task2) {

    return task1._expectedTimestamp < task2._expectedTimestamp;



But the overide function is never executed :( Can anybody help me??



You'd probably need to define 
bool operator< (const Task*, const Task*)


I've did it in the .h file and I get this error:

Overloaded 'operator<' must be a binary operator (has 3 parameters)

and If I make it friend:

Overloaded 'operator<' must have at least one parameter of class or enumeration type


Ah yes. Well, you can either write a comparator class yourself, or add the operator< to the class itself if poss.


I endup creating my own comparator. Thanks!