Original Post
I was wondering how to sort a list of structs after a specific membervariable.
Here''s some nice pseudocode
#include <list>
struct Node
{
int x, y;
int f, g, h;
Node *Parent;
};
std::list NodeList;
for(int i=0; i<10; i++)
{
Node node = {i,i,rand()%100,0,0,0};
NodeList.push_back(node);
}
there, now I wan''t to sort the list after the f membervariable in ascending order, if the list would have contained int''s instead of Node''s this would have worked:
NodeList.sort();
or for descending order:
std::greater great;
NodeList.sort(great);
Anyone here''s a guru on stl and can share som knowledge??
thanks for any help