C#: Ordering Return from TMDB API

trevor1940
trevor1940 used Ask the Experts™
on
Hi

How do you orderBy ReleeseDate  when returning person Information from the TMDB API

This returns the Movie Credits but isn't ordered
                     TMDbClient client = new TMDbClient("API KEY");

                     public DateTime dateTime { get; set; }
            // Set Default Date
            dateTime = DateTime.Parse("01 / 01 / 0001");
                var PersonKnownFor = client.GetPersonMovieCreditsAsync(TMDB_id).Result;
                foreach(var PKF in PersonKnownFor.Cast)
                {
                    
                    if (PKF.ReleaseDate != null)
                    {
                        dateTime = DateTime.Parse(PKF.ReleaseDate.ToString());
                    }

                }

Open in new window



                var PersonKnownFor = client.GetPersonMovieCreditsAsync(TMDB_id).Result;
                foreach(var PKF in PersonKnownFor.Cast.OrderBy(PersonKnownFor.Cast.d)  // I think you order it here but can't see how
                 {
                    
                    if (PKF.ReleaseDate != null)
                    {
                        dateTime = DateTime.Parse(PKF.ReleaseDate.ToString());
                    }
                  int Year = dateTime.Year;
                

Open in new window


Also

Hovering over ReleaseDate suggests it is a System Date Time object but to get at the year I had to do above unsure why
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
Can't test at the moment, but something like this should work:

foreach(var PKF in PersonKnownFor.OrderBy(x => x.ReleaseDate))

Open in new window

Author

Commented:
Thanx Chris

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial