Programming Language: C# (CSharp)

Class/Type: System

Method/Function: Sort

Examples at hotexamples.com: 22

System Sort is a package library in C# that provides sorting algorithms for arrays and lists. It contains methods that use quicksort, merge sort, heapsort, and insertion sort algorithms to sort elements in ascending or descending order.

**Example 1:** Sorting an array in ascending order using the Array.Sort method:

**Example 2:** Sorting a list in descending order using the List.Sort method with a custom comparison delegate:

int[] numbers = { 3, 2, 1, 4, 5 }; Array.Sort(numbers); // Result: { 1, 2, 3, 4, 5 }

ListThe System Sort package library is included in the .NET Framework and can be accessed by importing the System namespace.names = new List { "John", "Alice", "Bob", "Lisa" }; names.Sort((x, y) => -1 * x.CompareTo(y)); // Result: { "Lisa", "John", "Bob", "Alice" }

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods

Related in langs

Frequently Used Methods

Related