Use OrderByDescending to sort an string array in CSharp
Description
The following code shows how to use OrderByDescending to sort an string array.
Example
//from w w w . j ava 2 s .c om
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
public static void Main() {
string[] presidents = {"HTML", "CSS", "HTML5", "html", "css", "Java"};
IEnumerable<string> items = presidents.OrderByDescending(s => s);
foreach (string item in items)
Console.WriteLine(item);
}
}
The code above generates the following result.