title: Priority Queue Not Sorting
body: <p>Im trying to implement my own Huffman Coding algorithm and the priority queue for the C++ STL does not seem to be working correctly. I am taking characters from a string and inserting them into a priority queue by order of their frequency in the string. The code compiles and runs without error, the only thing is the tree seems to not be sorting correctly. Here is the code, </p>
  
  <pre><code>class Node {
   public:
    int freq;
    char data;
    Node(int &amp;f, char &amp;d) { freq=f; data=d; }
    bool operator&lt;(const Node* &amp;n) const { return n-&gt;freq &lt; this-&gt;freq; }
  };
  
  void Init(priority_queue&lt;Node*&gt; &amp;tree, string input) {
   map&lt;char,int&gt; probability;
   for(int i=0 ; i&lt;input.size() ; i++) {
     probability[input[i]]++;
   }
   map&lt;char,int&gt;::iterator it = probability.begin();
   for(it ; it != probability.end() ; it++) {
     Node* blah = new Node(it-&gt;second, (char&amp;) it-&gt;first);
     tree.push(blah);
   }
  </code></pre>
  
  <p>}</p>
  
  <p>what am I doing wrong?</p>
  
  <p>Thanks</p>