CSharp examples for LINQ:order by
Sort the filtered results into descending order
using System;//from w ww .j av a 2s . c o m using System.Linq; class MainClass { static void Main() { var values = new[] { 12, 9, 51, 0, 13, 7, 11, 14, 8, 5 }; foreach (var element in values) { Console.Write($" {element}"); } // sort the filtered results into descending order var sortFilteredResults = from value in values // data source is LINQ query filtered orderby value descending select value; // display the sorted results Console.Write("\nValues greater than 4, descending order (two queries):"); foreach (var element in sortFilteredResults) { Console.Write($" {element}"); } } }