Queryable.ThenByDescending : Queryable « System.Linq « C# / C Sharp by API






Queryable.ThenByDescending

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

public class CaseInsensitiveComparer : IComparer<string> {
    public int Compare(string x, string y) {
        return string.Compare(x, y, true);
    }
}

public class MainClass {
    public static void Main() {

        string[] words = { "a", "A", "b", "B", "C", "c" };

        var sortedWords =
            words.OrderBy(a => a.Length)
                    .ThenByDescending(a => a, new CaseInsensitiveComparer());

        foreach (var s in sortedWords) {
            Console.WriteLine(s);
        }
    }
}

   
    
  








Related examples in the same category

1.Queryable.All
2.Queryable.Concat
3.Queryable.Contains
4.Queryable.Count()
5.Queryable.Distinct()
6.Queryable.Except
7.Queryable.First
8.Queryable.First(filter)
9.Queryable.FirstOrDefault
10.Queryable.Intersect
11.Queryable.Last()
12.Queryable.LastOrDefault(filter)
13.Queryable.LongCount()
14.Queryable.LongCount(filter)
15.Queryable.Max
16.Queryable.Max(filter)
17.Queryable.Min()
18.Queryable.Min(filter)
19.Queryable.OfType
20.Queryable.OrderBy
21.Queryable.OrderByDescending
22.Queryable.Reverse
23.Queryable.SelectMany
24.Queryable.SequenceEqual
25.Queryable.Single
26.Queryable.SingleOrDefault
27.Queryable.Skip
28.Queryable.SkipWhile
29.Queryable.SkipWhile(filter)
30.Queryable.StartsWith
31.Queryable.Sum()
32.Queryable.Sum(projection)
33.Queryable.Take
34.Queryable.TakeWhile
35.Queryable.TakeWhile(filter)
36.Queryable.ThenBy
37.Queryable.ToArray
38.Queryable.ToDictionary
39.Queryable.ToDictionary(filter)
40.Queryable.ToList()
41.Queryable.Union