uses a compound orderby to sort a list of digits first by length of their name, and then alphabetically. : OrderBy : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » OrderBy »

 

uses a compound orderby to sort a list of digits first by length of their name, and then alphabetically.








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

public class MainClass {
    public static void Main() {

        string[] digits = { "zero", "one", "two", "three"};

        var sortedDigits =
            from d in digits
            orderby d.Length, d
            select d;

        Console.WriteLine("Sorted digits:");
        foreach (var d in sortedDigits) {
            Console.WriteLine(d);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» OrderBy