title: Passing a lambda expression as parameter to a method?
body: <p>It seems like it'd be a common requirement, but I cannot find a solution to this anywhere.</p>
  
  <p>I have a method which will <code>OrderBy</code> a collection depending on a parameter passed to it.</p>
  
  <p>I'd like to pass the contents of an 'OrderBy' to the method, but cannot work out how to do it.</p>
  
  <p><strong>What I've Tried</strong></p>
  
  <p>I've tried a switch with a string (i.e. if you pass 'Name' it'll hit the <code>case</code> which orders it by name), but this feels 'hacky' and unnecessary.</p>
  
  <p>I know it's something like <code>Func&lt;TEntity, TResult&gt;</code>, but I can't quite crack it.</p>
  
  <p>PSEUDO CODE:</p>
  
  <pre><code>GetOrderedCollection([NOT SURE] orderBy)
  {
    return collection.OrderBy(orderBy);
  }
  </code></pre>