title: Array distinct lambda comparisons with preference
body: <p>I have data with the following shape</p>
  
  <pre><code>someArray = [{ Name: "Some Class", TypeEnum: "Default" },
   { Name: "Some Class", TypeEnum: "Other" },
   { Name: "Some Class 2", TypeEnum: "Default" },
   { Name: "Some Class 2", TypeEnum: "Other" },
   { Name: "Some Class 3", TypeEnum: "Default" },
   { Name: "Some Class 4", TypeEnum: "Not Other" }]
  </code></pre>
  
  <p>Imagine each of those as objects in C#</p>
  
  <p>What I need is an array of distinct versions of that array, with preference given to a selected TypeEnum. For example if I have selected the TypeEnum of other, I still want it to default to Default if it can't find a version of that class with the "Other" TypeEnum</p>
  
  <p>e.g. With "Other" selected as the Type enum, the above data would look like</p>
  
  <pre><code> [{ Name: "Some Class", TypeEnum: "Other" },
   { Name: "Some Class 2", TypeEnum: "Other" },
   { Name: "Some Class 3", TypeEnum: "Default" }]
  </code></pre>
  
  <p>What I'm doing now is a lambda comparison from <a href="http://www.codekeep.net/snippets/b0255a8b-a5e5-4a7c-9f2a-f6a4c2f2c6f1.aspx" rel="nofollow">here</a></p>
  
  <pre><code>TypeEnum myEnum = "Other"
  someArray.Distinct((x,y) =&gt; x.Name == y.Name &amp;&amp; 
                     x.TypeEnum != myEnum &amp;&amp; 
                     (y.TypeEnum == myEnum || y.TypeEnum == "Default"));
  </code></pre>
  
  <p>I'm hoping that Distinct pops out any x from the array that get's a true from that expression.</p>
  
  <p>Am I wrong in how I think Distinct works. If I am, what should I use instead?</p>