Mid Collections

How can you sort a List<T> in C#?

Use the Sort() method or provide a custom comparer.

Example:

list.Sort(); // Default sort (ascending)

list.Sort((a, b) => b.CompareTo(a)); // Descending

More from C# Programming Tutorial

All questions for this course