
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Sort the words in lexicographical order in C#
Firstly, set a string array −
string[] arr = new string[] { "Indian", "Moroccon", "American", };
To sort the words in lexicographical order −
var sort = from a in arr orderby a select a;
Example
Let us see the complete code −
using System; using System.Linq; class Program { static void Main() { string[] arr = new string[] { "Indian", "Moroccon", "American", }; var sort = from a in arr orderby a select a; foreach(string res in sort) { Console.WriteLine(res); } } }
output
American Indian Moroccon
- Related Articles
- Sort the words in lexicographical order in Java
- Sort the words in lexicographical order in Python
- C++ Program to Sort Elements in Lexicographical Order (Dictionary Order)
- Java Program to Sort Elements in Lexicographical Order (Dictionary Order)
- Swift Program to Sort Elements in Lexicographical Order (Dictionary Order)
- Kotlin Program to Sort Elements in Lexicographical Order (Dictionary Order)
- Haskell Program to Sort Elements in Lexicographical Order (Dictionary Order)
- How to Sort Elements in Lexicographical Order (Dictionary Order) in Golang?
- Last Substring in Lexicographical Order in C++
- K-th Smallest in Lexicographical Order in C++
- How to Sort Words in Alphabetic Order using Python?
- Print all the combinations of a string in lexicographical order in C++
- Java program to sort words of sentence in ascending order
- Print all longest common sub-sequences in lexicographical order in C++
- Python program to sort out words of the sentence in ascending order

Advertisements