List<JObject> itemList = new List<JObject>();
foreach (JObject item in dataTable) {
itemList.Add( item);
}
itemList.Sort((a, b) => {
string a1 = a["location"].ToString();
string a2 = b["location"].ToString();
string k1 = a1.Substring(0, 1);
string k2 = a2.Substring(0, 1);
if (string.Equals(k1, k2))
{
return a1.Substring(1).ToInteger().CompareTo(a2.Substring(1).ToInteger());
}
else
{
return k1.CompareTo(k2);
}
});
标签:a1,string,c#,list,Substring,k2,k1,itemList,265
From: https://blog.51cto.com/u_14816966/9607960