Skip to content

Instantly share code, notes, and snippets.

@albilaga
Last active April 21, 2018 06:07
Show Gist options
  • Save albilaga/a6a26a721ee074c4dd9a9a81f326cd5d to your computer and use it in GitHub Desktop.
Save albilaga/a6a26a721ee074c4dd9a9a81f326cd5d to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
public class Test
{
public int Id { get; set; }
public string Name { get; set; }
}
class Solution
{
static void Main()
{
List<Test> tests = new List<Test>
{
new Test
{
Id=2,
Name="A"
},
new Test
{
Id=1,
Name="B"
},
new Test
{
Id=3,
Name="C"
}
};
var ordered = tests.OrderBy(x => x.Id);
foreach (var order in ordered)
{
Console.WriteLine($"order {order.Id} with name {order.Name}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment