I am using Linq and Lambda Operations in my projects and I needed to sort a List according to two properties of a class. Therefore, I used OrderBy().ThenBy() methods as below:>
The LINQ OrderBy(...).ThenBy(...)...ThenBy(...)
method chain form a single sort operation by multiple sort keys (using multi key comparer).
Thus, regardless of how many ThenBy(Descending)
methods do you include in the chain, the time complexity of the sort operation stays the typical for QuickSort O(N*logN) average / O(N2) worst case. Of course more keys you add, comparing two objects will take more time, but the complexity of the sort operation would not change.