VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-program-to-sort-a-list-of-string-names-using-the-linq-orderby-method/

⇱ C# Program to Sort a List of String Names Using the LINQ OrderBy() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# Program to Sort a List of String Names Using the LINQ OrderBy() Method

Last Updated : 23 Jul, 2025

Given a list of string names, now our task is to sort the names given in the list using the OrderBy() method of LINQ. This method is used to sort the elements in the collection in ascending order. While using this method in the LINQ query you don't need to add an extra condition to sort the list in ascending order.

Example: 

Input : [ "Raj", "Amisha", "Mohan", "Mohit", "Bhuvan" ]
Output : [ "Amisha", "Bhuvan", "Mohan", "Mohit", "Raj" ]

Input : [ "Amu", "Amisha", "Sumita", "Gita" ]
Output : [ "Amisha", "Amu", "Gita", "Sumita" ]

Approach:

1. Create and initialize a list of string types. For example arr.

2. Sorting the list(named arr) using OrderBy() method.

var finalres = arr.OrderBy(n => n);

3. Display the result using the foreach loop.

Example:

Output:

Sorted names are:
Avinash Naveen Raju Sandeep Vineeth 
Comment
Article Tags:

Explore