using System.Collections.Generic;
public string name { get; set; }
public string type { get; set; }
return ExtractSubstring(name);
private static int ExtractSubstring(string originalString)
string prefix = "Acoustic_Spectator_Info_";
int startIndex = originalString.IndexOf(prefix) + prefix.Length;
int endIndex = originalString.LastIndexOf(suffix);
if (startIndex != -1 && endIndex != -1 && endIndex > startIndex)
return int.Parse(originalString.Substring(startIndex, endIndex - startIndex).Replace("_", ""));
public List<ChildItem> childItems { get; set; }
public static void Main()
""name"": ""Acoustic_Spectator_Info_20230629.csv"",
""name"": ""Acoustic_Spectator_Info_20230629_11.csv"",
""name"": ""Acoustic_Spectator_Info_20230629_1.csv"",
""name"": ""Acoustic_Spectator_Info_20230629_2.csv"",
""name"": ""Acoustic_Spectator_Info_20230629_21.csv"",
""effectiveIntegrationRuntime"": ""AutoResolveIntegrationRuntime (UK South)"",
""executionDuration"": 0,
""integrationRuntimeQueue"": 0
""activityType"": ""PipelineActivity"",
""meterType"": ""AzureIR"",
""duration"": 0.016666666666666666,
Data data = JsonSerializer.Deserialize<Data>(json);
data.childItems.Sort((item1, item2) => item1.SortKey().CompareTo(item2.SortKey()));
string sortedJson = JsonSerializer.Serialize(data, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(sortedJson);