title: How do you Sort a DataTable given column and direction?
body: <p>I need to resort, in memory, a DataTable based on a column and direction that are coming from a GridView. The function needs to look like this:</p>
  
  <pre><code>public static DataTable resort(DataTable dt, string colName, string direction)
  {
      DataTable dtOut = null;
  
      ....
  }
  </code></pre>
  
  <p>I need help filling in this function. I think I can use a Select statement but I am not sure how. I can't click on Comments because of this browser but you can show me an in-place or new DataTable solution, either one. For the people showing me pointers, please, I need a coded function similar to the one prototyped.</p>
  
  <p>How about:</p>
  
  <pre><code>// ds.Tables[0].DefaultView.Sort="au_fname DESC";
     public static void Resort(ref DataTable dt, string colName, string direction)
     {
          string sortExpression = string.Format("{0} {1}", colName, direction);
          dt.DefaultView.Sort = sortExpression;
     }
  </code></pre>