title: Group List of Objects based on Property using Linq?
body: <p>I have an object:</p>
  
  <pre><code>public class SiteInfo
          {
              public string Title { get; set; }
              public string URL { get; set; }
              public string Type { get; set; }     
          }
  </code></pre>
  
  <p>That I am using to create a list:
   var sites = new List();</p>
  
  <pre><code>        foreach (SPWeb site in web.GetSubwebsForCurrentUser())
          {
              string sitetype = getConfigurationKey(site, "siteType");
              //If sites have a site type then add to list
              if (sitetype != "*ERROR*" &amp;&amp; sitetype != "*KEYNOTFOUND*")
              {
                  SiteInfo s = new SiteInfo();
                  s.Title = site.Title;
                  s.URL = site.Url;
                  s.Type = sitetype;
  
                  sites.Add(s);
              }
          }
          //sort list by type
          sites.Sort((x, y) =&gt; string.Compare(x.Type, y.Type));
  
          // serialize and send..    
          JavaScriptSerializer serializer = new JavaScriptSerializer();
          StringBuilder sbJsonResults = new StringBuilder();
          serializer.Serialize(sites, sbJsonResults);
  etc.....
  </code></pre>
  
  <p>However what I would like to do is group the sites by Type prior to serializing them. Is this possible using LINQ or some other method.</p>