title: LINQ order by delegate
body: <p>I have a collection of objects to be ordered by an object's field value. Current problem is that the order depends on a business logic.</p>
  
  <pre><code>public enum Order : byte {
      a = 1,
      b = 2,
      c = 3
  }
  
  public class Foo{
      public long A {get;set;}
      public long B {get;set;}
      public long C {get;set;}
  }
  
  public class Worker(){
      private Foo[] orderFoos(Foo[] foos, Func&lt;Order, long&gt; sort){
          return foos.OrderByDescending(f =&gt; sort(f)).ToArray(foos.Length);
      }
  
      public void Work(){
          Foo[] foos = getFoos();
  
          var orderByA = orderFoos(foos, f =&gt; f.A);
          var orderByB = orderFoos(foos, f =&gt; f.B);
          var orderByC = orderFoos(foos, f =&gt; f.C);
      }
  }
  </code></pre>
  
  <p>Compiler throws an error that <code>Argument 1: cannot convert from 'Foo' to 'Order'</code>. Are there any workarounds or solutions?</p>