title: Sorting Class Objects Stored In Deque
body: <p>I am trying to store email addresses written in a file and sort them by hits in the file.</p>
  <p>I am storing the email addresses and the number of hits in a class called emailAddress.</p>
  <p>I am managing the members of that class in a Deque in another class called AddressManager.</p>
  <p>The sort function I am trying to use is the sort from the algorithm library. <a href="http://www.java2s.com/Tutorial/Cpp/0540__STL-Algorithms-Sorting/Sortobjectsstoredindeque.htm" rel="nofollow noreferrer">Like this.</a></p>
  <pre><code>[emailAddress.released() returns the number of hits. addressQueue is my emailAddress Deque]
  
  bool AddressManager::swapTest(const emailAddress&amp; address1, const emailAddress&amp; address2)
  {
      cout&lt;&lt;&quot;Comparing: &quot;&lt;&lt;address1.released()&lt;&lt;&quot; to &quot;&lt;&lt;address2.released()&lt;&lt;endl;
      return address1.released()&gt;address2.released();
  }
  void AddressManager::sortAddresses()
  {
      
      sort(addressQueue.begin(),addressQueue.end(),
          swapTest);
  }
  </code></pre>
  <p>When I compile I get this error:</p>
  <pre><code>1&gt;c:\workspace\addressmanager.cpp(36): error C3867: 'AddressManager::swapTest': function call missing argument list; use '&amp;AddressManager::swapTest' to create a pointer to member
  1&gt;c:\workspace\addressmanager.cpp(36): error C2780: 'void std::sort(_RanIt,_RanIt)' : expects 2 arguments - 3 provided
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(3639) : see declaration of 'std::sort'
  </code></pre>
  <p>Can I pass swapTest to sort, or does it need to be defined outside of AddressManager somehow?
  Or could someone suggest a way to implement my own sort in AddressManager and not use the library version at all?</p>
  <p>Thanks,
  ANkh</p>