From the course: .NET Essentials: LINQ for XML

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Choose output order with OrderBy

Choose output order with OrderBy - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

Choose output order with OrderBy

- [Instructor] Sorting the query results is another popular action. In the LINQ world, that is done with the orderby keyword, or the orderby extension method. Here I am sorting by this Parsed catalog value. The syntax is orderby, and then the value you want to sort on. So you can see that it's going from lowest to highest on the catalog price. Of course, I can sort on other criteria. Let's take bidParsed, and orderby on that one. Now we're going from lowest to highest on the bid price. There's also the descending keyword. I put that here, and it'll reverse this order like that.

Contents