title: Sorting hands poker to find the winning hand
body: <p>I'm currently making a hand evaluator for poker (5 card). Firstly I deal the hands (not from the same deck) and then I check if each has a pair, three of a kind etc, once a match is found lets say a pair of aces, the hands rank will be set to 2 (1-10, 10 being best) and the value of the card will also be set so 14 for ace (1-14, ace highest).</p>
  
  <p>My problem is trying to sort the suckers, I've tried to overload the operator and then I tried to use sort and made a bool func that checks rank. Am I at least on the right path? Using sort didnt actually seem to sort them it just printed them out hand1,hand2,hand3 etc without any indication of even checking handrank and value (I used the bool func as the 3rd parameter..</p>
  
  <p>I have looked around for an hour or so and this is my last resort so any help whatsoever would be much appreciated.</p>
  
  <p><em>Also Hand is a class that generates a vector of 5 cards, checking if pair etc is done within the hand upon generation and hand rank and value are private class members.</em></p>
  
  <p>Thanks!</p>
  
  <pre><code>    bool operator &gt; (const Hand &amp;h1) const
  {
      return !((*this) &lt; h1.handRank);
  }
  bool operator &lt; (const Hand &amp;h1) const
  {
      if(handRank &lt; h1.handRank)
      {
         return handRank &lt; h1.handRank;
      }
      if(handRank == h1.handRank)
      {
         return highestValue &lt; h1.highestValue;
      }
  
  }
  </code></pre>
  
  <p>Hands are created in main as hand1, 2 etc.</p>
  
  <p>Each hand containsa vector of 5 cards, each card has a value and a suit.</p>
  
  <p>within each hand int handrank and int highestvalue(value of the highestcard in the current winning hand, eg 2 pair containing aces and 6's, aces would be the highest value)</p>
  
  <p>I have found whether a hand has a pair or a flush etc I just need to sort all of the hands in order of which would win, I'm stuck on how to compare all of the hands at once and see whether one wins or whether for example two have a royal flush</p>