34
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
5
namespace ConsoleApplication1
6
{
7
internal class Student
8
{
9
public int Id { get; set; }
10
public string Name { get; set; }
11
public int Rank { get; set; }
12
public int Age { get; set; }
13
}
14
15
public class Program
16
{
17
public static void Main(string[] args)
18
{
19
List<Student> students = new List<Student>();
20
students.Add(new Student { Id = 1, Name = "Ramesh", Rank = 1, Age = 39 });
21
students.Add(new Student { Id = 2, Name = "Kapil", Rank = 1, Age = 32 });
22
students.Add(new Student { Id = 3, Name = "Suresh", Rank = 2, Age = 45 });
23
students.Add(new Student { Id = 4, Name = "Mahesh", Rank = 2, Age = 39 });
24
25
var studentsOrderByRank = students.OrderBy(w => w.Rank).ThenBy(w => w.Age);
26
27
Console.WriteLine("Sorted Students:");
28
foreach (var student in studentsOrderByRank)
29
{
30
Console.WriteLine(student.Name);
31
}
32
}
33
}
34
}
Cached Result
Hello, please enter the name of the tutor group
>