The orderby
clause of a LINQ query sorts the output sequence. You can control the properties used for sorting, and specify ascending or descending order.
This sample uses a compound orderby
to sort a list of digits, first by length of their name, and then alphabetically by the name itself.
This sample uses a compound orderby
to sort a list of products, first by category, and then by unit price, from highest to lowest.
This sample uses Reverse
to create a list of all digits in the array whose second letter is 'i' that is reversed from the order in the original array.
Next: Custom comparisons » Previous: Ordering descending «