Académique Documents
Professionnel Documents
Culture Documents
OrderBy:
Try it
Example: OrderBy in Query Syntax VB.Net
Try it
orderByResult in the above example would contain following elements after
execution:
Bill
John
Ram
Ron
Steve
orderByDescendingResult in the above example would contain following elements
after execution:
Steve
Ron
Ram
John
Bill
The second overload method of OrderBy accepts object of IComparer along with
Func delegate type to use custom comparison for sorting.
Try it
Example: OrderBy in Method Syntax VB.Net
Note :Method syntax does not allow the decending keyword to sorts the collection
in decending order. Use OrderByDecending() method for it.
OrderByDescending:
OrderByDescending sorts the collection in descending order.
OrderByDescending is valid only with the Method syntax. It is not valid in query
syntax because the query syntax uses ascending and descending attributes as
shown above.
Example: OrderByDescending C#
Try it
Example: OrderByDescending VB.Net
A result in the above example would contain following elements after execution.
Steve
Ron
Ram
John
Bill
Please note that OrderByDescending is not supported in query syntax. Use the
decending keyword instead.
Multiple Sorting:
You can sort the collection on multiple fields seperated by comma. The given
collection would be first sorted based on the first field and then if value of first
field would be the same for two elements then it would use second field for sorting
and so on.
Age: 15