About This eBook by Bart De Smet

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Ordering Using the orderby Keyword

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, ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required