fork download
  1. using System;
  2. struct Item
  3. {
  4. public string Name;
  5. public int Price;
  6. }
  7.  
  8. class MainClass
  9. {
  10. static void Main(string[] args)
  11. {
  12. Item[] items = new[] {
  13. new Item { Name = "beer", Price = 2 },
  14. new Item { Name = "water", Price = 1 },
  15. new Item { Name = "wine", Price = 4 },
  16. new Item { Name = "juice", Price = 3 }};
  17. Array.Sort(items, (x, y) => x.Price.CompareTo(y.Price));
  18. foreach(Item i in items)
  19. {
  20. Console.WriteLine("{0} {1}", i.Name, i.Price);
  21. }
  22. }
  23. }
  24.  
Success #stdin #stdout 0.03s 34784KB
stdin
Standard input is empty
stdout
water 1
beer 2
juice 3
wine 4