CSharp examples for LINQ:order by
use orderby clause to sort original values in ascending order
using System;//from w w w.j a v a 2 s .c o m using System.Linq; class MainClass { static void Main() { var values = new[] {21, 91, 5, 0, 13, 17, 11, 4, 81, 5}; foreach (var element in values) { Console.Write($" {element}"); } // use orderby clause to sort original values in ascending order var sorted = from value in values // data source is values orderby value select value; // display sorted results Console.Write("\nOriginal array, sorted:"); foreach (var element in sorted) { Console.Write($" {element}"); } } }