Link to home
Start Free TrialLog in
Avatar of meow00
meow00

asked on

How do I sort a vector of struct using different methods ?

Hi experts,

typedef struct{
  int head ;
  int tail ;
  // ... blah
} Animal ;

I want to sort vector<Animal>. In some cases I want to sort by head; but in other cases, I want to sort by tail ....

so how do I do this ? should I write a predicator ? if so, how to do it ?

many thanks !
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial