title: LINQ query for Group by a key and then order by different column
body: <p>i want to display countof  records based on grouping by the id and name then i want to order them in their descending order of display. </p>
  
  <p>My database structure is as follows:-</p>
  
  <pre><code>rowid id    name         viewedon       viewedby
  1     a1   reporter     23/07/2014      a@yahoo.com
  2     a2   teacher      24/07/2014      test@gmail.com
  3     a1   reporter     24/07/2014      wayne@zz.com
  4     a2   teacher      24/07/2014      asdasd@zz.com
  5     a1   reporter     24/07/2014      btttt@zz.com
  6     a3   driver       26/02/2014      sfdf@yahoo.com 
  7     a4   operator     3/3/1991        asds@asd.com  
  8     a2   teacher      2/9/2011        tsdasd@gmail.com
  9     a1   reporter     3/5/1992        asdas@fg.com
  10    a4   operator     12/12/2005      asdss@a.com
  11    a1   reporter     2/2/2002        as@as.com
  12    a3   driver       10/7/2015       asdas@as.com
  </code></pre>
  
  <p>my Query is as follows</p>
  
  <pre><code>var q=from j in context.item 
         group jobs by new { j.Id, j.Name } into gr 
                                              select new DAO&lt;String&gt;
                                              {
                                                  Key = gr.Key.Name,
                                                  Count = gr.Count()                                   
                                              }).OrderByDescending(k =&gt; k.Count).Take(5).ToList();
  </code></pre>
  
  <p>This is giving correct result as follows:-</p>
  
  <pre><code>key           count 
  reporter       5
  teacher        3
  operator       2
  driver         2
  </code></pre>
  
  <p>reporter and teacher has high views so their count and order is justified .
  now i have problem with this result. operator and driver has same view count but  since driver has latest viewon date  so it should come before driver.</p>
  
  <p>so my result should be.</p>
  
  <pre><code> reporter 5
   teacher  3
   driver   2
   operator 2
  </code></pre>
  
  <p>what should be my LINQ to achieve this result</p>