this code:
string[] words = {"car", "boy", "apple", "bill", "crow", "brown"};
var groups = from w in words
group w by w[0] into g
select new {FirstLetter = g.Key, Words = g};
//orderby ???;
var wordList = groups.ToList();
//var wordList = groups.ToList().OrderBy(???);
wordList.ForEach(group =>
{
Console.WriteLine("Words that being with {0}:",
group.FirstLetter.ToString().ToUpper());
foreach(var word in group.Words)
Console.WriteLine(" " + word);
});
outputs this:
Words that being with C:
car
crow
Words that being with B:
boy
bill
brown
Words that being with A:
apple
But where do I put the orderby statement so that it lists out in alphabetical order?