DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Replacing JSON With Protobuf in Your Microservice Mesh: A Zero-Downtime Migration Blueprint
  • Generics in Java and Their Implementation
  • The Two-Pointers Technique
  • Mule 4 DataWeave(1.x) Script To Resolve Wildcard Dynamically

Trending

  • Building Enterprise File-Heavy AI Workflows: From Secure Uploads to Governed Document Intelligence
  • SSRF Prevention in C#: Securing File Imports From User-Supplied URLs
  • Beyond the Endpoint: How Agent Cards Enable Discovery, Interoperability, and Trust
  • What Cloud Engineers Actually Need to Know About AI Infrastructure

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. Data
  4. How To Sort String Array Using LINQ In C#

How To Sort String Array Using LINQ In C#

By 
Snippets Manager
·
Dec. 14, 11 · Code Snippet
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
11.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in
A string[] array and use a LINQ query expression to order its contents alphabetically. Note that we are ordering the strings, not the letters in the strings. 


using System;
using System.Linq;
class Program
{
    static void Main()
    {
	string[] a = new string[] {"Indonesian","Korean","Japanese","English","German"};
	var sort = from s in a	orderby s select s;
	foreach (string c in sort)
	{
	    Console.WriteLine(c);
	}
    }
}
/*OUTPUT
English
German
Indonesian
Japanese
Korean
*/


Eclipse IDE and Eclipse
Strings Sort (Unix) Data structure Data Types

Opinions expressed by DZone contributors are their own.

Related

  • Replacing JSON With Protobuf in Your Microservice Mesh: A Zero-Downtime Migration Blueprint
  • Generics in Java and Their Implementation
  • The Two-Pointers Technique
  • Mule 4 DataWeave(1.x) Script To Resolve Wildcard Dynamically

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook