title: Error When Applying 'GroupBy' LINQ Clause: "At least one object must implement IComparable."
body: <p>I'm trying to group a collection of custom entity object by username, then by position.  For a specific user, when I get to the second 'groupby', I always get the error:</p>
  
  <p>"At least one object must implement IComparable."</p>
  
  <p>The user in question has a username "#gill'n it".  When I execute the first "GroupBy" on that suername, it returns an anonymous type of Count=6, which is correct, but the number of elements in the type is 8 where the final two are null. I think those final two nulls are causing my problem, but I can't figure out where they're coming from.</p>
  
  <pre><code>     List&lt;CheatSheet&gt; allRelevantCheatSheets = CheatSheet.GetCheatSheets(Globals.FOOString)   // only grade football sheets
                                                .Where(x =&gt; x.Username != String.Empty)      // only grade user sheets
                                                .Where(x =&gt; x.SeasonCode == currrentFOOSeason)  // only grade sheet for the current season
                                                .Where(x =&gt; x.LastUpdated &lt; kickoffDate)         // only grade sheets before the kickoff date
                                                .Where(x =&gt; x.Positions.Count == 1)    // only grade single-position sheets
                                                .Where(x =&gt; (bool)x.MappedProperties[CSProperty.PPRLeague.ToString()] == false) // only grade standard socring sheets
                                                .ToList();
  
    foreach (var userSheetGroup in allRelevantCheatSheets.GroupBy(x =&gt; x.Username).OrderBy(x =&gt; x.Key))
    {
  
      int newCheatSheetID = 0;
      groupCounter++;
  
      // then group userSheets by position
      foreach (var targetUserPositionalSheetGroup in userSheetGroup.GroupBy(x =&gt; x.Positions[0]).OrderBy(x =&gt; x.Key))
      {
        // finally limit the type of sheet returned to only 1 (the latest one ordered by date), must cast to list in order to avoid casting error, then take first item
        CheatSheet userTopPositionSheet = (CheatSheet)targetUserPositionalSheetGroup.OrderBy(x =&gt; x.CheatSheetID).OrderBy(x =&gt; x.Positions[0]).OrderByDescending(x =&gt; x.LastUpdated).Take(1).ToList()[0];
        newCheatSheetID = ArchiveCheatSheet(userTopPositionSheet);
        if (newCheatSheetID == 0)
        {
          errorCounter++;
        }
        else
        {
          sheetCounter++;
  
          ArchiveCheatSheetItems(userTopPositionSheet.CheatSheetID, newCheatSheetID);
        }
      }
    }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/mjuiV.gif" alt="GroupBy Error"></p>