-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKod23_OrderByThenBy.cs
More file actions
35 lines (31 loc) · 968 Bytes
/
Kod23_OrderByThenBy.cs
File metadata and controls
35 lines (31 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp2
{
public class Order
{
public string Customer { get; set; }
public int Age { get; set; }
public string City { get; set; }
}
class Program
{
static void Main()
{
var orders = new List<Order>
{
new Order { Customer = "Anna", Age = 25, City = "Moscow" },
new Order { Customer = "Bob", Age = 30, City = "SPb" },
new Order { Customer = "Charlie", Age = 25, City = "Moscow" },
new Order { Customer = "Diana", Age = 28, City = "SPb" }
};
var finalSorted = orders.OrderBy(p => p.Age)
.ThenBy(p => p.Customer);
foreach (var groups in finalSorted)
{
Console.WriteLine($"{groups.Customer}: {groups.Age}");
}
}
}
}