标签:
// Sort dictionary by the value field List<KeyValuePair<int, int>> redBallsList = redBallsDict.ToList(); List<KeyValuePair<int, int>> blueBallsList = blueBallsDict.ToList(); redBallsList.Sort((firstPair, nextPair) => { //return nextPair.Value.CompareTo(firstPair.Value); return -1 * firstPair.Value.CompareTo(nextPair.Value); } ); blueBallsList.Sort((firstPair, nextPair) => { //return nextPair.Value.CompareTo(firstPair.Value); return -1 * firstPair.Value.CompareTo(nextPair.Value); } ); // Sort an int Arrary int[] PerfectBallsIntArr = new int[6]; for (int i = 0; i < 6; i++) { PerfectBallsIntArr[i] = Convert.ToInt32(PerfectBallsArr[i]); } Array.Sort(PerfectBallsIntArr);
How to sort the dictionary by the value field
标签:
原文地址:http://www.cnblogs.com/researcher/p/5004985.html