title: Sorting a collection of strings with special rules
body: <p>Preface: I stumbled across this at work and thought it was an interesting problem.</p>
  
  <p><strong>Preface EDIT:</strong> We already have a working solution, but I'm looking for other ways to approach this.</p>
  
  <hr>
  
  <p>Given a collection of <code>string</code>:</p>
  
  <pre><code>["2015", "2016 New", "2016 Used", "2017 New", "2017 Used", "2018"]
  </code></pre>
  
  <p>I want to sort this collection in descending order by year.</p>
  
  <p>However, I also want to apply a special rule, where a year containing the string <code>"New"</code> must come before the same year containing the string <code>"Used"</code>.</p>
  
  <p>Expected result:</p>
  
  <pre><code>["2018", "2017 New", "2017 Used", "2016 New", "2016 Used", "2015"]
  </code></pre>
  
  <hr>
  
  <p>Assumptions:</p>
  
  <ul>
  <li><p>If the collection contains a given year string containing <code>"New"</code>, the collection will always contain that same year containing <code>"Used"</code> (and vice versa), and will never contain the year by itself.</p>
  
  <pre><code>["2017 New", "2017", "2016 Used", "2016"] // invalid input
  </code></pre></li>
  <li><p>The years will be within range 1000-9999.</p></li>
  </ul>
  
  <hr>
  
  <p><strong>What is the best way to approach this problem?</strong></p>
  
  <hr>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>Here's our solution:</p>
  
  <pre><code>var l = new[] { "2015", "2016 New", "2016 Used", "2017 New", "2017 Used", "2018" };
  
  var sorted = l.OrderByDescending(i =&gt; i.Replace("Used", "Ased")).ToArray();
  // ["2018", "2017 New", "2017 Used", "2016 New", "2016 Used", "2015"]
  </code></pre>