How to group my List<> into categories
<p>I have this following class:</p>

<pre><code>public class TV
{
    public string GroupId { get; set; }
    public string Title { get; set; }
    public string Genre { get; set; }
}
</code></pre>

<p>Then I have this following list (which is dynamic created and will never be same):</p>

<pre><code>List&lt;TV&gt; myList = new List&lt;TV&gt;();
myList.Add(new TV { GroupId = "1", Title = "Title 1", Genre = "Genre A" });
myList.Add(new TV { GroupId = "1", Title = "Title 2", Genre = "Genre A" });
myList.Add(new TV { GroupId = "1", Title = "Title 3", Genre = "Genre A" });
myList.Add(new TV { GroupId = "3", Title = "Title 4", Genre = "Genre 18" });
myList.Add(new TV { GroupId = "A", Title = "Title 5", Genre = "Genre 18" });
myList.Add(new TV { GroupId = "A", Title = "Title 6", Genre = "Genre A" });
myList.Add(new TV { GroupId = "B", Title = "Title 7", Genre = "Genre A" });
myList.Add(new TV { GroupId = "C", Title = "Title 8", Genre = "Genre A" });
myList.Add(new TV { GroupId = "D", Title = "Title 9", Genre = "Genre 18" });
myList.Add(new TV { GroupId = "D", Title = "Title 10", Genre = "Genre A" });
myList.Add(new TV { GroupId = "D", Title = "Title 11", Genre = "Genre A" });
myList.Add(new TV { GroupId = "E", Title = "Title 12", Genre = "Genre A" });
</code></pre>

<p>I have the following (hardcoded) navigation categories that are links: </p>

<blockquote>
  <p>[0-9] [ABC] [DEF] [GHI] [JKL] [MNO] [PQR] [STU] [VWXYZ]</p>
</blockquote>

<p>I’m trying to loop myList and by looking at the <strong>GroupId</strong> property, I want to place it in the appropriate div so I end up having divs like this:</p>

<pre><code>&lt;div id="group-09"&gt;
&lt;div&gt;
    1, Title 1, Genre A
    1, Title 2, Genre A
    1, Title 3, Genre A
    3, Title 4, Genre 18
&lt;/div&gt;
&lt;/div&gt;

&lt;div id="group-ABC"&gt;
&lt;div&gt;
    A, Title 5, Genre 18
    A, Title 6, Genre A
    B, Title 7, Genre A
    C, Title 8, Genre A
&lt;/div&gt;
&lt;/div&gt;

&lt;div id="group-DEF"&gt;
&lt;div&gt;
    D, Title 9, Genre 18
    D, Title 10, Genre A
    D, Title 11, Genre A
    E, Title 12, Genre A
&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>I can’t seem to figure out the logic to properly do this!
Does anyone have a suggestion?
Thanks</p>
