title: Custom comparator for C++ STL Sort error expected primary-expression before ‘)’ token
body: <p>I need to use STL sort function with a custom comparator. If I directly used the comparator function as argument to sort, it gives error of non-static method. So I created a functor. Still it gives error: -</p>
  
  <pre><code>class Graph
  {
  private:
      struct edge
      {
          int src;
          int dest;
          int weightage;
      };
      typedef struct edge * edgePtr;
  
      list&lt;edgePtr&gt; edgeList ;
  
      struct compareEdgeWeightage
      {
          int src, dest, weightage;
          bool operator() (list&lt;edgePtr&gt;::iterator edge1ptr , list&lt;edgePtr&gt;::iterator edge2ptr ) const
          {
              edgePtr edge1 = *edge1ptr;
              edgePtr edge2 = *edge2ptr;
              return( (edge1-&gt;weightage) &lt; (edge2-&gt;weightage) ) ;
          }
      }; //struct compareEdgeWeightage
  
  
  public:
      Graph();
      void addEdge(int src, int dest, int weightage);
      void MST();
  
  };// class Graph
  
  
  void Graph::MST()
  {
      sort( edgeList.begin(),edgeList.end(),compareEdgeWeightage);
  } //MST
  </code></pre>
  
  <p>I have omitted other irrelevant functions and lines just for clarity. 
  Compiling it gives the error </p>
  
  <pre><code>error: expected primary-expression before ‘)’ token
  bash: syntax error near unexpected token `)'
  </code></pre>