C# Array Sort(T[])

Description

Array Sort (T[]) sorts the elements in an entire Array using the IComparable generic interface implementation of each element of the Array.

Syntax

Array.Sort<T>(T[]) has the following syntax.


public static void Sort<T>(
  T[] array
)

Parameters

Array.Sort<T>(T[]) has the following parameters.

  • T - The type of the elements of the array.
  • array - The one-dimensional, zero-based Array to sort.

Returns

Array.Sort<T>(T[]) method returns

Example


using System;/*from  w  ww . jav a 2  s .  c om*/
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        string[] myValues = {"2016", 
                              "1999", 
                              "2001", 
                              "2000", 
                              "2002", 
                              "2003"};

        Array.Sort(myValues);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version