fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8. class PersonData
  9. {
  10. public string Name { get; set; } // 氏名
  11. public int Height { get; set; } // 身長
  12. public int Weight { get; set; } // 体重
  13.  
  14. public PersonData(string _name, int _height, int _weight)
  15. {
  16. Name = _name; Height = _height; Weight = _weight;
  17. }
  18.  
  19. public string Output()
  20. {
  21. return (Name + "," + Height.ToString() + "," + Weight.ToString());
  22. }
  23. }
  24.  
  25. class Program
  26. {
  27. static void Main(string[] args)
  28. {
  29. PersonData[] personArray =
  30. {
  31. new PersonData("太郎", 180, 78),
  32. new PersonData("次郎", 179, 78),
  33. new PersonData("三郎", 178, 79),
  34. new PersonData("四郎", 177, 80),
  35. new PersonData("五郎", 176, 80)
  36. };
  37.  
  38.  
  39. foreach (PersonData p in personArray.OrderBy(n=>n.Weight).ThenBy(n=>n.Height))
  40. {
  41. Console.WriteLine(p.Output());
  42. }
  43.  
  44. Console.ReadKey();
  45. }
  46. }
  47. }
  48.  
Success #stdin #stdout 0.05s 34080KB
stdin
Standard input is empty
stdout
次郎,179,78
太郎,180,78
三郎,178,79
五郎,176,80
四郎,177,80