The ToLookup function can give you what you need.
cities.ToLookup(c => c.state, c => c.city);
This will create IGrouping<string, string> where you can iterate through the Key values ​​(states) and work with a set of city values.
To sort it first, just do cities.OrderBy(c => c.state).ThenBy(c => c.city) .
source share