title: C# LINQ Orderby - How does true/false affect orderby?
body: <p>I was studying a bit of LINQ ordering as I have a list of Ids, and I need to order them sequentially. However, there are certain ids that need to take precedence over the standard ordering.</p>
  
  <p>Given this C# code (which can be pasted into <a href="https://dotnetfiddle.net/" rel="noreferrer">.NET Fiddle</a> to test) the ordering works as I need it to, but I don't understand why a not (<code>!</code>) operator on a contains is giving me the correct ordering?</p>
  
  <p>My expected ordering output is (<code>5, 1, 2, 3, 4, 6, 7, 8, 9</code>).</p>
  
  <p>If I have a <a href="https://msdn.microsoft.com/en-us/library/system.linq.enumerable.contains(v=vs.110).aspx" rel="noreferrer"><code>Contains</code></a> in my ordering, shouldn't it give ordering priority to the rows that returned true? Instead it appears to give ordering priority to rows that return false.</p>
  
  <pre><code>using System.Linq;
  using System;
  
  public class Program
  {
    public static void Main()
    {
      var numbersToFilterBy = new [] {5, 11, 20};
  
      var x = new [] {new XClass(){Id = 1}, new XClass(){Id = 9}, new XClass(){Id = 5}, new XClass(){Id = 3}, new XClass(){Id = 4}, new XClass(){Id = 2}, new XClass(){Id = 6}, new XClass(){Id = 8}, new XClass(){Id = 7}};
  
      var trueData = (from data in x
                     orderby !numbersToFilterBy.Contains(data.Id), data.Id
                      select data).ToList();
  
      foreach(var item in trueData){
          Console.WriteLine(item.Id);
    }
  }
  
  public class XClass{
      public int Id{get;set;}
    }
  }
  </code></pre>
  
  <p>What is the explanation as to why this happens?</p>