title: Sorting a list of numbers first alphabetically and then numerically
body: <p>I have a requirement of sorting given numbers in alphabetical order first and then numerically ascending order.
  For example I have these numbers </p>
  
  <pre><code>{"10", "1", "2", "20", "200", "3", "300", "30", "201", "21"}
  </code></pre>
  
  <p>I want this order </p>
  
  <pre><code>{"1", "10", "2", "20", "21", "200", "201", "3", "30", "300"}
  </code></pre>
  
  <p>I wrote the following comparison function to sort them.</p>
  
  <pre><code>bool AlphaNumericCompare(const string &amp; str1, const string&amp; str2 )
  {
      int ind1 = 0, ind2 = 0;
      while ( ind1 &lt; str1.size() &amp;&amp; ind2 &lt; str2.size() )
      {
          if( str1[ind1] &lt; str2[ind2] )
              return true;
          else if( str1[ind1] &gt; str2[ind2] )
              return false;
          ind1++;
          ind2++;
      }
      if( ind1 == str1.size() &amp;&amp; ind2 == str2.size() )
      {
          return true;
      }
      else if( ind1 == str1.size() )
      {
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>But this function gives me the following order</p>
  
  <pre><code>{"1", "10", "2", "20",  "200", "201", "21", "3", "30", "300"}
  </code></pre>
  
  <p>Where 200 and 201 are placed before 21.
  Can anybody suggest how to change the above comparison function to get the desired sorting order?</p>