I have a list of Match objects:
IEnumerable<Match> matches
Match looks like this
public class Match
{
[JsonProperty("_id")]
public string Id { get; set; }
[JsonProperty("last_activity_date")]
public string LastActivityDate { get; set; }
[JsonProperty("messages")]
public MatchMessage[] Messages { get; set; }
}
My MatchMessage class looks like this:
public class MatchMessage
{
[JsonProperty("_id")]
public string Id { get; set; }
[JsonProperty("message")]
public string Message { get; set; }
[JsonProperty("sent_date")]
public string SentDate { get; set; }
}
Now, I want to sort my list of Matches by the SentDate property in MatchMessage and I'm having a very hard time figuring this out.
i tried:
var newList = matchList.OrderBy(match => match.Messages.OrderBy(x => x.SentDate));
but I get an error when I do that. I've been googling for a while and can't find a solution to this. How do I go about doing this?