title: Sort with two criteria, string ascending, int ascending
body: <p>How can I perform a sort on two different criteria?</p>
  
  <p>For example, I have person objects like:</p>
  
  <p><code>Person</code> with properties <code>FirstName</code> (string), <code>LastName</code>, and <code>Rank</code> (int).</p>
  
  <p>Example data like so:</p>
  
  <pre><code>Xavier    Smith 1
  Alexander Smith 2
  Alexander Smith 1
  Bob       Hawke 2
  </code></pre>
  
  <p>It should sort on FirstName alphabetically, then on rank, e.g. resulting:</p>
  
  <pre><code>Alexander Smith 1
  Alexander Smith 2
  Bob       Hawke 2
  Xavier    Smith 1
  </code></pre>
  
  <p>So far, I have tried the following, but it isn't working properly:</p>
  
  <p><code>peopleList</code> is <code>List&lt;Person&gt;</code></p>
  
  <pre><code>peopleList.Sort(new Comparison&lt;Person&gt;((x,y) =&gt; x.Rank.CompareTo(y.Rank)));
  peopleList.Sort(new Comparison&lt;Person&gt;((x, y) =&gt; string.Compare(x.Name, y.Name)));
  </code></pre>
  
  <p>Thanks</p>
  
  <p><strong>edit:</strong> to avoid changing my code too much, I really want to keep list, if I change the above lines to:</p>
  
  <pre><code>peopleList.OrderBy(person =&gt; person.FirstName).ThenBy(person =&gt; person.Rank).ToList();
  </code></pre>
  
  <p>Would give the exact same list just sorted properly, correct?</p>