fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public delegate int MyComparer<T>(T left, T right);
  7.  
  8. public static void Sort<T>(List<T> elements, MyComparer<T> comparer)
  9. {
  10. elements.Sort((l, r) => comparer(l, r));
  11. }
  12.  
  13. public static void Main()
  14. {
  15. var elems = new List<int> { 3, 2, 1 };
  16. Sort(elems, (l, r) => l.CompareTo(r));
  17. elems.ForEach(Console.WriteLine);
  18. }
  19. }
Success #stdin #stdout 0.03s 24216KB
stdin
Standard input is empty
stdout
1
2
3