title: dynamic sort in linq
body: <p>please consider this scenario:</p>
  
  <p>I have a list of a class with about 50 fields.I want to have a Combobox that user can select according to what field list will sort.For example if user select "F1" list sort according to "F1".</p>
  
  <p>I don't want to sort with <code>if-else</code> for every fields.I see this topic :</p>
  
  <p><a href="https://stackoverflow.com/questions/617088/sorting-a-gridview-when-databinding-a-collection-or-list-of-objects">Sorting a gridview when databinding a collection or list of objects</a></p>
  
  <p>but I can't use of it's answer. How I can use <code>Expression Tree</code> for this purpose?</p>
  
  <h2>thanks</h2>
  
  <p><strong>Edit 1)</strong> :</p>
  
  <p>According to dear @Thom Smith answer I wrote this code:</p>
  
  <pre><code> using (NorthwindModel1.NorthwindEntities2 ent = new NorthwindModel1.NorthwindEntities2())
      {
          var query = from o in ent.Orders
                      where o.OrderID &lt; 10257
                      select o;
  
          query.OrderBy("CustomerID", SortDirection.Ascending);
  
          GridView1.DataSource = query;
          GridView1.DataBind();
      }
  </code></pre>
  
  <p>but it was not sorted. if I wrote that code in this way:</p>
  
  <pre><code>GridView1.DataSource = query.OrderBy(o=&gt;o.CustomerID);
  </code></pre>
  
  <p>it being sort. where is the problem?</p>