Ordering Using the
Sorting elements by one or more criteria is another commonly used querying action, which is supported through the
orderby keyword. The basic idea is to specify a key selector function that selects an ordering key for each element in the input sequence. Upon enumerating over the query result object, the ordering key is obtained for all elements and used to sort the elements. Ordering by a key can be done either ascending (the default) or descending, using the corresponding keywords.
Besides doing just a single ordering (hence selecting just a single key), it’s possible to specify secondary and n-ary orderings, too. For example, you might want to sort a list of products first by price in a descending fashion, ...