There are two formats for any given Linq expression with a custom sort comparer:
Format 1
var query =
source
.Select(x => new { x.someProperty, x.otherProperty } )
.OrderBy(x => x, new myComparer());
Format 2
var query =
from x in source
orderby x // comparer expression goes here?
select new { x.someProperty, x.otherProperty };
Question:
What is the syntax for the order-by expression in the second format?
Not the question:
How to use a custom comparer as shown in the first format.
Bonus credit:
Are there actual, formal names for the two Linq formats listed above?
It doesn’t exist. From the orderby clause documentation:
You wrote it correctly. You can pass the
IComparer<T>as you wrote.Format 1 is called “Method-Based Syntax” (from previous link), and Format 2 is “Query Expression Syntax” (from here).