This post will discuss how to sort a list of strings in C#.

1. Using Enumerable.OrderBy Method

A simple solution to get a sorted copy of a List is using the Enumerable.OrderBy method. It sorts all items contained in a sequence in ascending order according to a key or a specified comparer. The following example demonstrates its usage to sort elements of a list.

Download  Run Code

2. Using List<T>.Sort Method

A concise and efficient solution to in-place sort elements of a list is using the List<T>.Sort method. We can use it to sort the complete list or a portion of it with the specified comparer. The following example demonstrates its usage to sort the values of a list.

Download  Run Code

That’s all about sorting a list of strings in C#.