several functors for redefining order for sort function of vector
<p>I have the following data structure:</p>

<pre><code>typedef vector&lt; vector&lt;int&gt; &gt; MxInt2d;
typedef vector&lt; vector&lt;double&gt; &gt; MxDouble2d;

 class QSweep{   
 public:
 ....
 static MxDouble2d myPoints_;
 MxInt2d myEdges_;
 MxInt2d sweepEvents;

 class order{
 public:
    bool operator() (const vector&lt;int&gt;&amp; edge1, const vector&lt;int&gt;&amp; edge2){
            return (myPoints_[edge1[0]][0]&lt;myPoints_[edge2[0]][0])|| 
                       (myPoints_[edge1[0]][0]==myPoints_[edge2[0]][0]&amp;&amp; 
                        myPoints_[edge1[0]][1]&lt;myPoints_[edge2[0]][1]) 
                   ||
                    (myPoints_[edge1[0]][0]==myPoints_[edge2[0]][0]&amp;&amp; 
                         myPoints_[edge1[0]][1]==myPoints_[edge2[0]][1]&amp;&amp; 
                     getSlope(myPoints_[edge1[0]][0],myPoints_[edge1[0][1],  
                                  myPoints_[edge1[1]][0],myPoints_[edge1[1]][1])
                     &lt;
                         getSlope(myPoints_[edge2[0][0],myPoints_[edge2[0][1],    
                                  myPoints_[edge2[1]][0],myPoints_[edge2[1]][1]));
                    }
};
static double getSlope(double a, double b, double c, double d);
static double computeDet(double a, double b, double c, double d, double x, double y);
</code></pre>

<p>};</p>

<p>I use the functor for order() when defining the constructor in the following way:</p>

<pre><code> QSweep::QSweep(const MxDouble2d&amp; myPoints, const MxInt2d&amp; myEdges){ 
....
    //code here for initializing myPoints_, myEdges_
sort(myEdges_.begin(),myEdges_.end(),order());
 }
</code></pre>

<p>In this way my data myEdges_ are arranged when initialized using the functor order().
Now I want to arrange the data sweepEvents (which has the same type as myEdges_ using the predefined data type from C++ vector) using a totally different criteria, that is I do not want to use the function getSlope(...) but the function computeDet(...) for sweepEvents.
So I was thinking I still need other functor for redefining the &lt; of sort() for the vector data type right? So I would have to write a new functor order1() in which I use the data computed with computeDet(...) and then I call the sort on my sweepEvents data types:</p>

<pre><code> sort(sweepEvents.begin(),sweepEvents.end(),order1());
</code></pre>

<p>I am not sure if this is the good solution? can I redefine in several ways &lt; if I use different names for the functor?
Is someone has some suggestions I would be really grateful.
Thank you in advance,
madalina</p>

<p>No the two functors does not use any common code.
I have written the second functor insede the QSweep class as this:</p>

<pre><code> class orderDet{
public:
 bool operator() (const vector&lt;int&gt;&amp; edgeSW1, const vector&lt;int&gt;&amp; edgeSW2   
                              ,const vector&lt;int&gt;&amp; edgeC){
  return  
          (
          computeDet(myPoints_[edgeSW1[0]],myPoints_[edgeSW1[1]],myPoints_[edgeC[0]]) 
           &lt; 
          computeDet(myPoints_[edgeSW2[0]],myPoints_[edgeSW2[1]],myPoints_[edgeC[0]])
           );
  }}
</code></pre>

<p>and I called it like:</p>

<pre><code> sort(sweepEvents.begin(), sweepEvents.end(), orderDet());
</code></pre>

<p>But I got the following compilation error:</p>

<pre><code> error: no match for call to '(QSweepComplete::orderDet) (std::vector&lt;int,  
 std::allocator&lt;int&gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;)'
 ./QSweepComplete.h:68: note: candidates are: bool 
 QSweepComplete::orderDet::operator()(const std::vector&lt;int, std::allocator&lt;int&gt;&gt;&amp;,   
 const std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;, const std::vector&lt;int, 
 std::allocator&lt;int&gt; &gt;&amp;)
</code></pre>

<p>I am guessing the parameter do not match, as the third parameter of orderDet(...., edgeC) is not part of sweepEvents list as the others are but is part of the variable myEdges_...
Maybe one can give me some suggestions on how to implement this functor?</p>

<p>thank you in advance.
best wishes,
madalina</p>
