using System;
using System.Collections.Generic;
using System.Linq;
namespace Sort
{
class Program
{
static void Main(string[] args)
{
List<Student> lists = new List<Student>();
IEnumerable<Student> query;
lists.Add(new Student("00010", "和田", "B", "A", 55, 30));
lists.Add(new Student("00003", "ダル", "B", "B", 50, 30));
lists.Add(new Student("00002", "田中", "O", "A", 40, 70));
lists.Add(new Student("00007", "野茂", "A", "B", 15, 50));
lists.Add(new Student("00006", "黒田", "AB", "A", 55, 10));
lists.Add(new Student("00009", "伊良部", "AB", "C", 85, 90));
lists.Add(new Student("00008", "長谷川", "B", "C", 60, 45));
lists.Add(new Student("00005", "前田", "O", "A", 60, 30));
lists.Add(new Student("00004", "菊池", "O", "B", 50, 20));
lists.Add(new Student("00001", "平野", "A", "C", 30, 40));
lists.Add(new Student("00011", "大家", "AB", "B", 25, 45));
lists.Add(new Student("00012", "佐々木", "O", "A", 90, 80));
query = lists
.OrderBy(value =>
{
int result = 0;
switch (value.BloodType)
{
case "A":
result = 1;
break;
case "B":
result = 3;
break;
case "O":
result = 0;
break;
case "AB":
result = 2;
break;
}
return result;
})
.ThenBy(value =>
{
int result = 0;
switch (value.Department)
{
case "A":
result = 2;
break;
case "B":
result = 0;
break;
case "C":
result = 1;
break;
}
return result;
})
.ThenByDescending(value => value.National);
Console.WriteLine("生徒番号\t名前\t血液型\tクラス\t国語\t算数");
foreach (Student a in query)
{
Console.WriteLine("{0}\t\t{1}\t{2}\t{3}\t{4}\t{5}"
, a.StudentNumber
, a.Name
, a.BloodType
, a.Department
, a.National
, a.Mathematics
);
}
}
}
}