fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class Program
  5. {
  6. static void Main(string[] args)
  7. {
  8. var list = new List<KeyValuePair<int, string>>();
  9.  
  10. list.Add(new KeyValuePair<int, string>(31, "Jan"));
  11. list.Add(new KeyValuePair<int, string>(28, "Feb"));
  12. list.Add(new KeyValuePair<int, string>(31, "Mar"));
  13. list.Add(new KeyValuePair<int, string>(30, "Apr"));
  14. list.Add(new KeyValuePair<int, string>(31, "Jan"));
  15.  
  16. //list.Sort(delegate(KeyValuePair<int, string> kvp1, KeyValuePair<int, string> kvp2)
  17. //{
  18. // return kvp2.Key - kvp1.Key;
  19. //});
  20. list.Sort((KeyValuePair<int, string> kvp1, KeyValuePair<int, string> kvp2) => (kvp2.Key - kvp1.Key));
  21.  
  22. foreach (var kvp in list)
  23. {
  24. Console.WriteLine("{0} {1}", kvp.Key, kvp.Value);
  25.  
  26. }
  27. }
  28. }
  29.  
Success #stdin #stdout 0.04s 34728KB
stdin
Standard input is empty
stdout
31 Mar
31 Jan
31 Jan
30 Apr
28 Feb