Use a ThenBy clause to add more ordering condition in CSharp
Description
The following code shows how to use a ThenBy clause to add more ordering condition.
Example
/*from w w w . ja v a2 s .c om*/
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
public static void Main() {
string[] presidents = {"ant", "arding", "arrison", "eyes", "over", "Jackson"};
IEnumerable<string> items = presidents.OrderBy(s => s.Length).ThenBy(s => s);
foreach (string item in items)
Console.WriteLine(item);
}
}
The code above generates the following result.