日期:2014-05-18 浏览次数:20982 次
string str="AA:12;BB:18;CC:111;DD:23;EE:45;FFF:2;"; Console.Write(string.Join(";", str.Split(new char[]{';'},StringSplitOptions.RemoveEmptyEntries).OrderByDescending(x => int.Parse(x.Split(':')[1])).ToList())); Console.Read();
------解决方案--------------------
string str = "AA:12;BB:18;CC:111;DD:23;EE:45;FFF:2"; string[] arr = str.Split(';'); Array.Sort(arr, (v1, v2) => int.Parse(v1.Split(':')[1]).CompareTo(int.Parse(v2.Split(':')[1]))); str = string.Join(";", arr);