title: C# DataTable - GroupBy then OrderBy
body: <p>I have a DataTable that contains 5 columns.</p>
  
  <p>Activity (string)
  Clock In (DateTime)
  Clock Out (DateTime)
  Total (double)
  Type (int)</p>
  
  <p>I am needing to GroupBy the Clock Out DateTime.Date and within that OrderBy the Type.</p>
  
  <p>So essentially, if I have data, I want it grouped/order like this:</p>
  
  <pre><code>Activity    Clock In           Clock Out          Total    Type
  
  Drawing     09/16/13 13:30     09/16/13 13:32     0.02     1
  Drawing     09/16/13 13:40     09/16/13 13:42     0.02     1
  Testing     09/16/13 13:50     09/16/13 13:52     0.02     1
  Testing     09/16/13 13:30     09/16/13 13:34     0.04     2
  Testing     09/16/13 13:40     09/16/13 13:54     0.14     2
  
  
  Drawing     09/17/13 13:50     09/17/13 13:52     0.02     1
  Testing     09/17/13 13:30     09/17/13 13:34     0.04     2
  Testing     09/17/13 13:40     09/17/13 13:54     0.14     2
  
  
  Testing     09/18/13 13:52     09/18/13 13:54     0.02     2
  </code></pre>
  
  <p>I have all the data in a DataTable already, I just need help with the grouping...</p>
  
  <p>Any thoughts??  I have tried:</p>
  
  <pre><code>groupedSortedTbl = dt.AsEnumerable()
                      .GroupBy(d =&gt; d.Field&lt;DateTime&gt;("CLOCK_OUT").Date)
                      .SelectMany(g =&gt; g.OrderBy(t =&gt; t.Field&lt;int&gt;("Type")))
                      .CopyToDataTable();
  </code></pre>