{
"30": {
"3":{},
"0":{}
},
"11":{}
}
public static void Main()
{
string json = @"{300:[{'Lygis':2,'Patiekalo_ID':30}],110:[{'Lygis':3,'Patiekalo_ID':31}]}";
var jObj = (JObject)JsonConvert.DeserializeObject(json);
Sort(jObj);
string newJson = jObj.ToString();
Console.WriteLine(newJson);
}
static void Sort(JObject jObj)
{
var props = jObj.Properties().ToList();
foreach (var prop in props)
{
prop.Remove();
}
foreach (var prop in props.OrderBy(p=>Int32.Parse(p.Name)))
{
jObj.Add(prop);
if(prop.Value is JObject)
Sort((JObject)prop.Value);
}
}