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
Use the Sort() method or provide a custom comparer.
Example:
list.Sort(); // Default sort (ascending)
list.Sort((a, b) => b.CompareTo(a)); // Descending