I have a class called Movies with the following variables declared:
string Title;
string Plot;
string MPAA;
string Certification;
string[] Genres;
I create a List of Movies with the following code:
Movie m = new Movie(strTitle, strPlot, strMPAA, strCertification, strArrGenres);
MovieList.Add(m);
I’m now trying to figure out the best way to sort the list. I need to do two sorts, the first is a simple Sort by Title. I attempted to use LINQ, but I can’t figure out how to access the variable within the Movie correctly.
The second one will be more tricky. I need to sort by Genre THEN Title. Each movie of course can have multiple Genres, and I know I will end up with multiple movies since the movie will be in each Genre.
I did not understand how you want to sort by Genres if they are contained inside the movies, maybe you want to filter by genre and then sort by title?
EDIT: Selecting movies with genre and ordering by Genre then Title (as per comment):
Output: