How can I use STL sort in c++ to sort some values in the class?
- by Morteza M.
I have a class named Graph, in this class I have a member named V, it is a vector. I have a struct named Edge, and a list of Edges. like below:
struct Edge{
int u;
int v;
Edge(int u,int v){
this-u=u;
this-v=v;
}
};
class Graph{
vector < Vertex > V;
.
.
.
int edgeCmp(Edge* x,Edge* y){
return (V[x-v].dv].d)?1:0;
}
void someFunction(){
list backEdges;
backEdges.sort(&Graph::edgeCmp);
}
}
But it doesn't work!! may someone help me to do such a thing?