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);
}
}
}
Related examples in the same category