Summarize the sorting methods of key-value pairs. [Csharp]/* use the sort dictionary. By default, only SortedDictionary <DateTime, String> dd = new SortedDictionary <DateTime, String> (); DateTime dt = DateTime. now; dd. add (dt, "bbb"); dd. add (dt. addDays (-1), "ccc"); dd. add (dt. addDays (1), "aaa"); // you can use List to obtain the descending key or value List <String> lst = new List <String> (dd. values); lst. reverse (); * // * use Linq to query Dictionary <DateTime, String> dd = new Dictionary <DateTime, String> (); DateTime dt = DateTime. now; dd. add (dt, "bbb"); dd. add (dt. addDays (-1), "ccc"); dd. add (dt. addDays (1), "aaa"); var result = from pair in dd orderby pair. key descending select pair; List <String> lst = new List <String> (); foreach (var kv in result) {www.2cto.com lst. add (kv. value);} // or Dictionary <DateTime, String> dd2 = result. toDictionary (p => p. key, p => p. value); * // use the extended method Dictionary <DateTime, String> dd = new Dictionary <DateTime, String> (); DateTime dt = DateTime. now; dd. add (dt, "bbb"); dd. add (dt. addDays (-1), "ccc"); dd. add (dt. addDays (1), "aaa"); Dictionary <DateTime, String> dicAsc = dd. orderBy (p => p. key ). toDictionary (p => p. key, p => p. value); Dictionary <DateTime, String> dicDesc = dd. orderByDescending (p => p. key ). toDictionary (p => p. key, p => p. value );