Sort c# list of objects by variable

c#, int, list, sorting

Solution

var foos = new List<Foo>(); 
// consider this is your class with the integer variable called layer

var ordered = foos.OrderBy(f => f.layer);

`Enumerable.OrderBy`

Problem

I have a class with an integer variable called "layer", there is a list of these classes, which I want to sort in ascending order. How would I go about doing this? I've tried one or two LINQ methods i've found on here, but to no avail.

Original source