Sort a List in C# (DESC and ASC) – Programming, Pseudocode Example, C# Programming Example
Loops / Iteration Statement Methods

Sort a List in C# (DESC and ASC)

Sorting a list of simple types like int, string, char etc. is straight forward. Just invoke the sort() method on the list instance and the data will be automatically sorting in asceding order.

If you want the data to be retrieved in descending order, use Reverse() methodvon the list instance.

Now it’s time to look at the first simple example of sorting a List.

Example 1:

Output:

 

The code example here shows that I first sort the list and then revers the sorted list:

Example 2:

Output:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.