title: Linq order by conditional
body: <p>I'm searching through a list of images and I want to find the "best fit". i.e., if the image set contains an imager taller than <code>H</code> pixels, I want to get the <em>shortest</em> image with a height greater than <code>H</code>, if the image set <em>does not</em> contain an image with a height bigger than <code>H</code>, then I just want to take the tallest overall image.</p>
  
  <p>Here's what I've got so far:</p>
  
  <pre><code>var imageFile =
      from f in imageObj.Files
      orderby f.Height &gt; height descending, f.Height ascending, f.Height descending
      select f;
  </code></pre>
  
  <p>Obviously this won't work -- I can't figure out how to put a conditional in there.</p>
  
  <p>Any suggestions?</p>
  
  <hr>
  
  <p>Please note that my question is different than <a href="https://stackoverflow.com/questions/1606454/conditional-orderby-sort-order-in-linq">this one</a> where the conditional can be pre-evaluated; mine depends on <code>f</code>.</p>