sort function c# code example
Example 1: c# sort array
Array.Sort(arr);
Example 2: c# sort array
int[] sortedCopy = from element in copyArray
orderby element ascending select element;
Example 3: sorting array in c#
int[] arr = { 3, 6, 4, 1 };
Array.Sort(arr);
Array.Sort(arr);
Array.Reverse(arr);
Example 4: c# sort list
using System;
class Program
{
static void Main()
{
string[] colors = new string[]
{
"orange",
"blue",
"yellow",
"aqua",
"red"
};
Array.Sort(colors);
foreach (string color in colors)
{
Console.WriteLine(color);
}
}
}