title: how to sort a vector of pairs?
body: <p>I am trying to sort a vector of <code>pair&lt;int, T&gt;</code> (where T is the templated value type of the class) and codeblocks is giving me massive amounts of errors i dont understand why. is there there some special syntax required to sort <code>vector&lt;pair&lt;int, T&gt; &gt;</code>? i did make the comparison function, which did not use T at all</p>
  
  <p>here's the code</p>
  
  <pre><code>  bool sortlevel(pair&lt;int, T&gt; a, pair&lt;int, T&gt; b){
      return a.first &lt; b.first;
    }
  
    void get_level(Node&lt;T&gt; * root, vector &lt;pair&lt;int, T&gt; &gt; &amp; order, int level = 0){
      // changes the tree to a vector
      if (root){
          order.push_back(pair(level, root -&gt; value));
          get_level(root -&gt; left, order, level + 1);
          get_level(root -&gt; right, order, level + 1);
      }
    }
  
    void level_order(ostream &amp; ostr ) {
      vector&lt;pair&lt;int, T&gt; &gt; order;
      get_level(root_, order);
      sort(order.begin(), order.end(), sortlevel);
      int max_level = order[order.size() - 1] -&gt; first;
      int x = 0;
      int current_level = order[x] -&gt; first;
      while (x &lt; order.size()){
          for(int y = 0; y &lt; current_level - x; y++)
              cout &lt;&lt; "\t";
          while (order[x] -&gt; first == current_level){
              cout &lt;&lt; order[x] -&gt; second &lt;&lt; " ";
              x++;
          }
      }
    }
  </code></pre>