I am trying to sort a vector of nodes.
I followed the advice from this thread and overloaded my
struct's < operator. However I am not getting a sorted list after sort is called.
struct node
{
int frequency ;
char data;
bool operator < (const node& n1) const
{
return (frequency < n1.frequency);
}
};
I call sort by the following:
vector<node*> test
//fill test with nodes
sort(test.begin(),test.end());
Output:
Presort data is: 1,1,2,3,3,1,2,1,1
Postsort data is: 3,2,1,1,1,1,2,1,3