C# Program to Sort a List of String Names Using the LINQ OrderBy() Method Last Updated : 06 Dec, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: C# // C# program to sort a list of string type // Using OrderBy() method using System; using System.Linq; using System.Collections.Generic; class GFG{ static void Main(string[] args) { // Creating and initializing list of string type List<string> arr = new List<string>(){ "Raju", "Avinash", "Sandeep", "Vineeth", "Naveen" }; // Using order by method we sort the list var finalres = arr.OrderBy(n => n); // Display the list Console.WriteLine("Sorted names are:"); foreach (string data in finalres) { Console.Write(data + " "); } } } Output: Sorted names are: Avinash Naveen Raju Sandeep Vineeth Comment More infoAdvertise with us Next Article C# Program to Sort Student Names in Descending Order using LINQ R raghu135ram Follow Improve Article Tags : C# C# Programs CSharp LINQ Similar Reads C# Program to Sort a List of Integers Using the LINQ OrderBy() Method Given a list of integers, now our task is to sort the given list of integers. So we use the OrderBy() method of LINQ. This method is used to sort the elements in the collection in ascending order. This method is overloaded in two different ways: OrderBy<TSource, TKey>(IEnumerable<TSource 2 min read C# Program to Sort Student Names in Descending Order using LINQ Given a list of student names, now our task is to sort the names given in the list in descending order using the LINQ, This task can be done using OrderByDescending() method of LINQ. This method is used to sort the elements in the collection in descending order. While using this method in the LINQ q 2 min read C# Program to Find Integer Numbers from the List of Objects and Sort them Using LINQ Given a list of objects, we need to find the integer double numbers from the list of objects and sort them using LINQ. So this task can be done using the OfType() method and then the sorting of numbers can be done by using OrderBy() method. Let discuss them one by one along with their syntax: 1. OfT 2 min read C# Program to Reverse the List of Cities using LINQ Given a list of city names, we need to reverse the list of cities and this can be done using the reverse() method in LINQ. The Reverse() method reverses the sequence of the elements in the specified list. it is available in both Queryable and Enumerable classes. It will return an ArgumentNullExcepti 1 min read C# Program to Sort a List of Employees Based on Salary using LINQ Given a list of employees, now we sort the list of employees according to their salary using LINQ. So to this task, we use the OrderBy() method. This method is used to sort the elements of the specified sequence in ascending order. Example: Input: {id = 101, Name = Rohit, Salary = 50000, Department 3 min read C# Program to Demonstrate the Example of LINQ Intersect() Method with OrderBy() Method LINQ is known as Language Integrated Query and it is introduced in .NET 3.5. It provides the power to .NET languages to create queries to retrieve data from the data source. In this article we will demonstrate the example of the LINQ intersect() method with OrderBy() method. 1. intersect() Method: T 3 min read Like