title: How do I order by and group by in a Linq to objects query?
body: <p>How do I order by and group by in a Linq query?</p>
  
  <p>I tried..</p>
  
  <pre><code>Dim iPerson = From lqPersons In objPersons Where Len(lqPersons.Person) &gt; 0 Group lqPersons By key = lqPersons.Name Into Group Order By Group descending Select Group, key
  
      For Each i In iPerson
          tmp = tmp &amp; vbNewLine &amp; i.key &amp; ", " &amp; i.Group.Count
      Next
  </code></pre>
  
  <p>The above works if I remove the <code>Order By Group Descending</code> claus, but with it, I get an error on the <code>Next</code> statement..</p>
  
  <blockquote>
    <p>At least one object must implement IComparable.</p>
  </blockquote>
  
  <p>My query is to obtain a list of the people in my class/object with how many times their name is used as an item of the class/object.</p>
  
  <p>I.e.</p>
  
  <p>Joe, 4 | 
  James, 5 | 
  Mike, 4</p>
  
  <p>Does anyone have any ideas what I'm doing wrong?</p>