Below program first create int array and then apply query on that array and sort with the help of linq
using System;
using System.Linq;
class SortArrayLinqProgram
{
static void Main()
{
int[] array1 = { 5, 4, 1, 2, 3 };
var query = from element in array1
orderby element
select element;
int[] array2 = query.ToArray();
foreach (int value in array2)
{
Console.WriteLine(value);
}
}
} | |