https://stackoverflow.com/questions/53391878 - Version 3

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
					
public class Program
{
	public static void Main()
	{
        string json = @"
            [
              {
                ""Name"": ""Joe Schmoe"",
                ""Birthday"": null
              },
              {
                ""Name"": ""Jane Doe"",
                ""Birthday"": ""1988-10-06T00:00:00""
              }
            ]";
		
		List<Person> people = JsonConvert.DeserializeObject<List<Person>>(json);
		people = people.OrderBy(p => p.LastName).ThenBy(p => p.FirstName).ToList();
		json = JsonConvert.SerializeObject(people, Formatting.Indented);
		Console.WriteLine(json);
	}
}

public class Person  // Version 3
{
	public string FirstName { get; set; }
	public string LastName { get; set; }
	public DateTime? Birthday { get; set; }

	// This property is here to support transitioning from the Version 2 model to Version 3
	[JsonProperty]
	private string Name
	{
		set
		{
			if (value != null)
			{
				string[] parts = value.Trim().Split(' ');
				if (parts.Length > 0) FirstName = parts[0];
				if (parts.Length > 1) LastName = parts[1];
			}
		}
	}
}
;