OrderByDescending and ThenBy : ThenBy « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;


public class MainClass{

   public static void Main(string[] args){   
         String[] TestData = {"One", "Two", "Three", "Four",
                              "Five", "Six", "Seven", "Eight", 
                              "Nine", "Ten"};

         var ThisQuery = TestData.OrderByDescending(ThisKey => ThisKey.Length).
            ThenBy(ThisKey => ThisKey.Substring(0, 1));

         foreach (var ThisElement in ThisQuery)
            Console.WriteLine(ThisElement);


   }
}








22.73.ThenBy
22.73.1.Using an OrderBy and a ThenBy clause with a custom comparer to sort first by word length and then by a case-insensitive descending sort of the words in an array.
22.73.2.First ThenBy Prototype
22.73.3.OrderByDescending and ThenBy