title: How to sort the list order using Linq?
body: <p>Below is the order of the Data that I get in the list object from other service.</p>
  <p><img src="https://i.stack.imgur.com/RN8k9.png" alt="Data in List" /></p>
  <blockquote>
  <p>How can I sort the order of above list in the below order?</p>
  </blockquote>
  <p>Level 0 Class<br />
  Level 0 S-Class<br />
  Level 1 Class<br />
  Level 1 S-Class<br />
  Level 2 Class<br />
  Level 2 S-Class<br />
  Level 0 Lesson<br />
  Level 0 S-Lesson<br />
  Level 1 Lesson<br />
  Level 1 S-Lesson<br />
  Level 2 Lesson<br />
  Level 2 S-Lesson</p>
  <p>So far I have tried as below, but only getting the right order for ProgramId &quot;E&quot;.</p>
  <pre><code>    myList.OrderByDescending(x =&gt; x.ProgramId== &quot;E&quot;)
            .ThenBy(x =&gt; x.Level)
            .ThenBy(x =&gt; x.Special = True)
            .ThenBy(x =&gt; x.Special = False)
            .ThenByDescending(x =&gt; x.ProgramId== &quot;B&quot;)
            .ThenBy(x =&gt; x.Level)
            .ThenBy(x =&gt; x.Special = True)
            .ThenBy(x =&gt; x.Special = False);
  </code></pre>
  <p>Below is the sorting logic that I am trying to apply:</p>
  <ul>
  <li>It should be sorted based on ProgramId first followed by Level and Followed by Special = false, followed by Special = true.</li>
  <li>Within ProgramId, sorting order should be &quot;E&quot; followed by &quot;B&quot;.</li>
  <li>Within Level, sorting order should be Level 0 followed by Level 1 followed by Level 2</li>
  </ul>
  <p>Any help suggestion on this would be appreciated!</p>