list.sort() w3schools C# code example
Example 1: C# order a sorted list by key
SortedList<string,bool> l = new SortedList<string, bool>();
l.Add("a", true);
l.Add("b", false);
l.Add("c", true);
l.Add("d", false);
var orderByVal = l.OrderBy(kvp => kvp.Key);
Example 2: sorting array in c#
int[] arr = { 3, 6, 4, 1 };
// arr will be { 1, 3, 4, 6 }
Array.Sort(arr);
// arr will be { 6, 4, 3, 1 }
Array.Sort(arr);
Array.Reverse(arr);