ArrayList.Sort 메서드

정의

ArrayList 또는 그 일부에 포함된 요소를 정렬합니다.

오버로드

Sort()

전체 ArrayList의 요소를 정렬합니다.

Sort(IComparer)

지정된 비교자를 사용하여 전체 ArrayList에 있는 요소를 정렬합니다.

Sort(Int32, Int32, IComparer)

지정된 비교자를 사용하여 ArrayList의 요소 범위에 있는 요소를 정렬합니다.

Sort()

전체 ArrayList의 요소를 정렬합니다.

public:
 virtual void Sort();
public virtual void Sort ();
abstract member Sort : unit -> unit
override this.Sort : unit -> unit
Public Overridable Sub Sort ()

예외

ArrayList이 읽기 전용인 경우

예제

다음 코드 예제에서는 의 값을 정렬하는 방법을 보여 있습니다 ArrayList.

using namespace System;
using namespace System::Collections;
void PrintValues( IEnumerable^ myList );
int main()
{
   
   // Creates and initializes a new ArrayList.
   ArrayList^ myAL = gcnew ArrayList;
   myAL->Add( "The" );
   myAL->Add( "quick" );
   myAL->Add( "brown" );
   myAL->Add( "fox" );
   myAL->Add( "jumps" );
   myAL->Add( "over" );
   myAL->Add( "the" );
   myAL->Add( "lazy" );
   myAL->Add( "dog" );
   
   // Displays the values of the ArrayList.
   Console::WriteLine( "The ArrayList initially contains the following values:" );
   PrintValues( myAL );
   
   // Sorts the values of the ArrayList.
   myAL->Sort();
   
   // Displays the values of the ArrayList.
   Console::WriteLine( "After sorting:" );
   PrintValues( myAL );
}

void PrintValues( IEnumerable^ myList )
{
   IEnumerator^ myEnum = myList->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Object^ obj = safe_cast<Object^>(myEnum->Current);
      Console::WriteLine( "   {0}", obj );
   }

   Console::WriteLine();
}

/* 
 This code produces the following output.

 The ArrayList initially contains the following values:
    The
    quick
    brown
    fox
    jumps
    over
    the
    lazy
    dog

 After sorting:
    brown
    dog
    fox
    jumps
    lazy
    over
    quick
    the
    The
 */
using System;
using System.Collections;

public class SamplesArrayList1
{
    public static void Main()
    {
        // Creates and initializes a new ArrayList.
        ArrayList myAL = new ArrayList();
        myAL.Add("The");
        myAL.Add("quick");
        myAL.Add("brown");
        myAL.Add("fox");
        myAL.Add("jumps");
        myAL.Add("over");
        myAL.Add("the");
        myAL.Add("lazy");
        myAL.Add("dog");

        // Displays the values of the ArrayList.
        Console.WriteLine("The ArrayList initially contains the following values:");
        PrintValues(myAL);

        // Sorts the values of the ArrayList.
        myAL.Sort();

        // Displays the values of the ArrayList.
        Console.WriteLine("After sorting:");
        PrintValues(myAL);
    }

    public static void PrintValues(IEnumerable myList)
    {
        foreach (Object obj in myList)
            Console.WriteLine("   {0}", obj);
        Console.WriteLine();
    }
}

/*
This code produces the following output.

The ArrayList initially contains the following values:
   The
   quick
   brown
   fox
   jumps
   over
   the
   lazy
   dog

After sorting:
   brown
   dog
   fox
   jumps
   lazy
   over
   quick
   the
   The
*/
Imports System.Collections

Public Class SamplesArrayList

    Public Shared Sub Main()

        ' Creates and initializes a new ArrayList.
        Dim myAL As New ArrayList()
        myAL.Add("The")
        myAL.Add("quick")
        myAL.Add("brown")
        myAL.Add("fox")
        myAL.Add("jumps")
        myAL.Add("over")
        myAL.Add("the")
        myAL.Add("lazy")
        myAL.Add("dog")

        ' Displays the values of the ArrayList.
        Console.WriteLine("The ArrayList initially contains the following values:")
        PrintValues(myAL)

        ' Sorts the values of the ArrayList.
        myAL.Sort()

        ' Displays the values of the ArrayList.
        Console.WriteLine("After sorting:")
        PrintValues(myAL)

    End Sub

    Public Shared Sub PrintValues(myList As IEnumerable)
        Dim obj As [Object]
        For Each obj In  myList
            Console.WriteLine("   {0}", obj)
        Next obj
        Console.WriteLine()
    End Sub

End Class


' This code produces the following output.
'
' The ArrayList initially contains the following values:
'    The
'    quick
'    brown
'    fox
'    jumps
'    over
'    the
'    lazy
'    dog
'
' After sorting:
'    brown
'    dog
'    fox
'    jumps
'    lazy
'    over
'    quick
'    the
'    The

설명

이 메서드는 QuickSort 알고리즘을 사용하는 를 사용합니다 Array.Sort. QuickSort 알고리즘은 비교 정렬(불안정한 정렬이라고도 함)입니다. 즉, "보다 작거나 같음" 비교 작업으로 최종 정렬 목록에서 먼저 발생해야 하는 두 요소 중 어느 것이 결정됩니다. 그러나 두 요소가 같으면 원래 순서가 유지되지 않을 수 있습니다. 반면, 안정적인 정렬은 같은 요소의 순서를 유지합니다. 안정적인 정렬을 수행하려면 이 메서드의 다른 오버로드와 함께 사용할 사용자 지정 IComparer 인터페이스를 구현해야 합니다.

평균적으로 이 메서드는 연산입니다 O(n log n) . 여기서 n 는 이 Count고, 최악의 경우 연산입니다 O(n^2) .

추가 정보

적용 대상

Sort(IComparer)

지정된 비교자를 사용하여 전체 ArrayList에 있는 요소를 정렬합니다.

public:
 virtual void Sort(System::Collections::IComparer ^ comparer);
public virtual void Sort (System.Collections.IComparer comparer);
public virtual void Sort (System.Collections.IComparer? comparer);
abstract member Sort : System.Collections.IComparer -> unit
override this.Sort : System.Collections.IComparer -> unit
Public Overridable Sub Sort (comparer As IComparer)

매개 변수

comparer
IComparer

요소를 비교할 때 사용하는 IComparer 구현입니다.

또는

각 요소의 IComparable 구현을 사용할 null 참조(Visual Basic에서는 Nothing)입니다.

예외

ArrayList이 읽기 전용인 경우

두 요소를 비교하는 동안 오류가 발생했습니다.

comparer에 대해 null이 전달되었으며, 목록의 요소가 IComparable을 구현하지 않습니다.

예제

다음 코드 예제에서는 기본 비교자와 정렬 순서를 반대로 하는 사용자 지정 비교자를 사용하여 의 ArrayList 값을 정렬하는 방법을 보여 줍니다.

using namespace System;
using namespace System::Collections;
void PrintIndexAndValues( IEnumerable^ myList );
ref class myReverserClass: public IComparer
{
private:

   // Calls CaseInsensitiveComparer.Compare with the parameters reversed.
   virtual int Compare( Object^ x, Object^ y ) sealed = IComparer::Compare
   {
      return ((gcnew CaseInsensitiveComparer)->Compare( y, x ));
   }

};

int main()
{
   
   // Creates and initializes a new ArrayList.
   ArrayList^ myAL = gcnew ArrayList;
   myAL->Add( "The" );
   myAL->Add( "quick" );
   myAL->Add( "brown" );
   myAL->Add( "fox" );
   myAL->Add( "jumps" );
   myAL->Add( "over" );
   myAL->Add( "the" );
   myAL->Add( "lazy" );
   myAL->Add( "dog" );
   
   // Displays the values of the ArrayList.
   Console::WriteLine( "The ArrayList initially contains the following values:" );
   PrintIndexAndValues( myAL );
   
   // Sorts the values of the ArrayList using the default comparer.
   myAL->Sort();
   Console::WriteLine( "After sorting with the default comparer:" );
   PrintIndexAndValues( myAL );
   
   // Sorts the values of the ArrayList using the reverse case-insensitive comparer.
   IComparer^ myComparer = gcnew myReverserClass;
   myAL->Sort( myComparer );
   Console::WriteLine( "After sorting with the reverse case-insensitive comparer:" );
   PrintIndexAndValues( myAL );
}

void PrintIndexAndValues( IEnumerable^ myList )
{
   int i = 0;
   IEnumerator^ myEnum = myList->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Object^ obj = safe_cast<Object^>(myEnum->Current);
      Console::WriteLine( "\t[{0}]:\t{1}", i++, obj );
   }

   Console::WriteLine();
}

/* 
This code produces the following output.
The ArrayList initially contains the following values:
        [0]:    The
        [1]:    quick
        [2]:    brown
        [3]:    fox
        [4]:    jumps
        [5]:    over
        [6]:    the
        [7]:    lazy
        [8]:    dog

After sorting with the default comparer:
        [0]:    brown
        [1]:    dog
        [2]:    fox
        [3]:    jumps
        [4]:    lazy
        [5]:    over
        [6]:    quick
        [7]:    the
        [8]:    The

After sorting with the reverse case-insensitive comparer:
        [0]:    the
        [1]:    The
        [2]:    quick
        [3]:    over
        [4]:    lazy
        [5]:    jumps
        [6]:    fox
        [7]:    dog
        [8]:    brown 
*/
using System;
using System.Collections;

public class SamplesArrayList2
{
    public class myReverserClass : IComparer
    {
        // Calls CaseInsensitiveComparer.Compare with the parameters reversed.
        int IComparer.Compare(Object x, Object y)
        {
            return ((new CaseInsensitiveComparer()).Compare(y, x));
        }
    }

    public static void Main()
    {
        // Creates and initializes a new ArrayList.
        ArrayList myAL = new ArrayList();
        myAL.Add("The");
        myAL.Add("quick");
        myAL.Add("brown");
        myAL.Add("fox");
        myAL.Add("jumps");
        myAL.Add("over");
        myAL.Add("the");
        myAL.Add("lazy");
        myAL.Add("dog");

        // Displays the values of the ArrayList.
        Console.WriteLine("The ArrayList initially contains the following values:");
        PrintIndexAndValues(myAL);

        // Sorts the values of the ArrayList using the default comparer.
        myAL.Sort();
        Console.WriteLine("After sorting with the default comparer:");
        PrintIndexAndValues(myAL);

        // Sorts the values of the ArrayList using the reverse case-insensitive comparer.
        IComparer myComparer = new myReverserClass();
        myAL.Sort(myComparer);
        Console.WriteLine("After sorting with the reverse case-insensitive comparer:");
        PrintIndexAndValues(myAL);
    }

    public static void PrintIndexAndValues(IEnumerable myList)
    {
        int i = 0;
        foreach (Object obj in myList)
            Console.WriteLine("\t[{0}]:\t{1}", i++, obj);
        Console.WriteLine();
    }
}

/*
This code produces the following output.
The ArrayList initially contains the following values:
        [0]:    The
        [1]:    quick
        [2]:    brown
        [3]:    fox
        [4]:    jumps
        [5]:    over
        [6]:    the
        [7]:    lazy
        [8]:    dog

After sorting with the default comparer:
        [0]:    brown
        [1]:    dog
        [2]:    fox
        [3]:    jumps
        [4]:    lazy
        [5]:    over
        [6]:    quick
        [7]:    the
        [8]:    The

After sorting with the reverse case-insensitive comparer:
        [0]:    the
        [1]:    The
        [2]:    quick
        [3]:    over
        [4]:    lazy
        [5]:    jumps
        [6]:    fox
        [7]:    dog
        [8]:    brown
*/
Imports System.Collections

Public Class SamplesArrayList

   Public Class myReverserClass
      Implements IComparer

      ' Calls CaseInsensitiveComparer.Compare with the parameters reversed.
      Public Function Compare( ByVal x As Object, ByVal y As Object) As Integer _
         Implements IComparer.Compare
         Return New CaseInsensitiveComparer().Compare(y, x)
      End Function 'IComparer.Compare

   End Class

   Public Shared Sub Main()

      ' Creates and initializes a new ArrayList.
      Dim myAL As New ArrayList()
      myAL.Add("The")
      myAL.Add("quick")
      myAL.Add("brown")
      myAL.Add("fox")
      myAL.Add("jumps")
      myAL.Add("over")
      myAL.Add("the")
      myAL.Add("lazy")
      myAL.Add("dog")

      ' Displays the values of the ArrayList.
      Console.WriteLine("The ArrayList initially contains the following values:")
      PrintIndexAndValues(myAL)

      ' Sorts the values of the ArrayList using the default comparer.
      myAL.Sort()
      Console.WriteLine("After sorting with the default comparer:")
      PrintIndexAndValues(myAL)

      ' Sorts the values of the ArrayList using the reverse case-insensitive comparer.
      Dim myComparer = New myReverserClass()
      myAL.Sort(myComparer)
      Console.WriteLine("After sorting with the reverse case-insensitive comparer:")
      PrintIndexAndValues(myAL)

   End Sub

   Public Shared Sub PrintIndexAndValues(myList As IEnumerable)
      Dim i As Integer = 0
      Dim obj As [Object]
      For Each obj In  myList
         Console.WriteLine(vbTab + "[{0}]:" + vbTab + "{1}", i, obj)
         i = i + 1
      Next obj
      Console.WriteLine()
   End Sub

End Class


'This code produces the following output.
'The ArrayList initially contains the following values:
'        [0]:    The
'        [1]:    quick
'        [2]:    brown
'        [3]:    fox
'        [4]:    jumps
'        [5]:    over
'        [6]:    the
'        [7]:    lazy
'        [8]:    dog
'
'After sorting with the default comparer:
'        [0]:    brown
'        [1]:    dog
'        [2]:    fox
'        [3]:    jumps
'        [4]:    lazy
'        [5]:    over
'        [6]:    quick
'        [7]:    the
'        [8]:    The
'
'After sorting with the reverse case-insensitive comparer:
'        [0]:    the
'        [1]:    The
'        [2]:    quick
'        [3]:    over
'        [4]:    lazy
'        [5]:    jumps
'        [6]:    fox
'        [7]:    dog
'        [8]:    brown

설명

메서드를 Sort 사용하여 인터페이스를 구현하는 사용자 지정 비교자를 사용하여 개체 목록을 정렬합니다 IComparer . 에 전달하는 nullcomparer경우 이 메서드는 각 요소의 구현을 IComparable 사용합니다. 이 경우 목록에 포함된 개체가 인터페이스를 구현하는지 또는 예외가 IComparer 발생하는지 확인해야 합니다.

또한 구현을 IComparable 사용하면 목록이 비교 정렬(불안정한 정렬이라고도 함)을 수행합니다. 즉, 두 요소가 같으면 순서가 유지되지 않을 수 있습니다. 반면, 안정적인 정렬은 같은 요소의 순서를 유지합니다. 안정적인 정렬을 수행하려면 사용자 지정 IComparer 인터페이스를 구현해야 합니다.

평균적으로 이 메서드는 연산입니다 O(n log n) . 여기서 n 는 이 Count고, 최악의 경우 연산입니다 O(n^2) .

추가 정보

적용 대상

Sort(Int32, Int32, IComparer)

지정된 비교자를 사용하여 ArrayList의 요소 범위에 있는 요소를 정렬합니다.

public:
 virtual void Sort(int index, int count, System::Collections::IComparer ^ comparer);
public virtual void Sort (int index, int count, System.Collections.IComparer comparer);
public virtual void Sort (int index, int count, System.Collections.IComparer? comparer);
abstract member Sort : int * int * System.Collections.IComparer -> unit
override this.Sort : int * int * System.Collections.IComparer -> unit
Public Overridable Sub Sort (index As Integer, count As Integer, comparer As IComparer)

매개 변수

index
Int32

정렬할 범위의 0부터 시작하는 인덱스입니다.

count
Int32

정렬할 범위의 길이입니다.

comparer
IComparer

요소를 비교할 때 사용하는 IComparer 구현입니다.

또는

각 요소의 IComparable 구현을 사용할 null 참조(Visual Basic에서는 Nothing)입니다.

예외

index가 0보다 작은 경우

또는

count가 0보다 작은 경우

indexcountArrayList의 올바른 범위를 지정하지 않습니다.

ArrayList이 읽기 전용인 경우

두 요소를 비교하는 동안 오류가 발생했습니다.

예제

다음 코드 예제에서는 기본 비교자와 정렬 순서를 반대로 하는 사용자 지정 비교자를 사용하여 의 요소 범위에서 ArrayList 값을 정렬하는 방법을 보여 줍니다.

using namespace System;
using namespace System::Collections;
void PrintIndexAndValues( IEnumerable^ myList );
ref class myReverserClass: public IComparer
{
private:

   // Calls CaseInsensitiveComparer.Compare with the parameters reversed.
   virtual int Compare( Object^ x, Object^ y ) = IComparer::Compare
   {
      return ((gcnew CaseInsensitiveComparer)->Compare( y, x ));
   }

};

int main()
{
   
   // Creates and initializes a new ArrayList.
   ArrayList^ myAL = gcnew ArrayList;
   myAL->Add( "The" );
   myAL->Add( "QUICK" );
   myAL->Add( "BROWN" );
   myAL->Add( "FOX" );
   myAL->Add( "jumps" );
   myAL->Add( "over" );
   myAL->Add( "the" );
   myAL->Add( "lazy" );
   myAL->Add( "dog" );
   
   // Displays the values of the ArrayList.
   Console::WriteLine( "The ArrayList initially contains the following values:" );
   PrintIndexAndValues( myAL );
   
   // Sorts the values of the ArrayList using the default comparer.
   myAL->Sort( 1, 3, nullptr );
   Console::WriteLine( "After sorting from index 1 to index 3 with the default comparer:" );
   PrintIndexAndValues( myAL );
   
   // Sorts the values of the ArrayList using the reverse case-insensitive comparer.
   IComparer^ myComparer = gcnew myReverserClass;
   myAL->Sort( 1, 3, myComparer );
   Console::WriteLine( "After sorting from index 1 to index 3 with the reverse case-insensitive comparer:" );
   PrintIndexAndValues( myAL );
}

void PrintIndexAndValues( IEnumerable^ myList )
{
   int i = 0;
   IEnumerator^ myEnum = myList->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Object^ obj = safe_cast<Object^>(myEnum->Current);
      Console::WriteLine( "\t[{0}]:\t{1}", i++, obj );
   }

   Console::WriteLine();
}

/* 
This code produces the following output.
The ArrayList initially contains the following values:
        [0]:    The
        [1]:    QUICK
        [2]:    BROWN
        [3]:    FOX
        [4]:    jumps
        [5]:    over
        [6]:    the
        [7]:    lazy
        [8]:    dog

After sorting from index 1 to index 3 with the default comparer:
        [0]:    The
        [1]:    BROWN
        [2]:    FOX
        [3]:    QUICK
        [4]:    jumps
        [5]:    over
        [6]:    the
        [7]:    lazy
        [8]:    dog

After sorting from index 1 to index 3 with the reverse case-insensitive comparer:
        [0]:    The
        [1]:    QUICK
        [2]:    FOX
        [3]:    BROWN
        [4]:    jumps
        [5]:    over
        [6]:    the
        [7]:    lazy
        [8]:    dog
*/
using System;
using System.Collections;

public class SamplesArrayList3
{
    public class myReverserClass : IComparer
    {
        // Calls CaseInsensitiveComparer.Compare with the parameters reversed.
        int IComparer.Compare(Object x, Object y)
        {
            return ((new CaseInsensitiveComparer()).Compare(y, x));
        }
    }

    public static void Main()
    {
        // Creates and initializes a new ArrayList.
        ArrayList myAL = new ArrayList();
        myAL.Add("The");
        myAL.Add("QUICK");
        myAL.Add("BROWN");
        myAL.Add("FOX");
        myAL.Add("jumps");
        myAL.Add("over");
        myAL.Add("the");
        myAL.Add("lazy");
        myAL.Add("dog");

        // Displays the values of the ArrayList.
        Console.WriteLine("The ArrayList initially contains the following values:");
        PrintIndexAndValues(myAL);

        // Sorts the values of the ArrayList using the default comparer.
        myAL.Sort(1, 3, null);
        Console.WriteLine("After sorting from index 1 to index 3 with the default comparer:");
        PrintIndexAndValues(myAL);

        // Sorts the values of the ArrayList using the reverse case-insensitive comparer.
        IComparer myComparer = new myReverserClass();
        myAL.Sort(1, 3, myComparer);
        Console.WriteLine("After sorting from index 1 to index 3 with the reverse case-insensitive comparer:");
        PrintIndexAndValues(myAL);
    }

    public static void PrintIndexAndValues(IEnumerable myList)
    {
        int i = 0;
        foreach (Object obj in myList)
            Console.WriteLine("\t[{0}]:\t{1}", i++, obj);
        Console.WriteLine();
    }
}

/*
This code produces the following output.
The ArrayList initially contains the following values:
        [0]:    The
        [1]:    QUICK
        [2]:    BROWN
        [3]:    FOX
        [4]:    jumps
        [5]:    over
        [6]:    the
        [7]:    lazy
        [8]:    dog

After sorting from index 1 to index 3 with the default comparer:
        [0]:    The
        [1]:    BROWN
        [2]:    FOX
        [3]:    QUICK
        [4]:    jumps
        [5]:    over
        [6]:    the
        [7]:    lazy
        [8]:    dog

After sorting from index 1 to index 3 with the reverse case-insensitive comparer:
        [0]:    The
        [1]:    QUICK
        [2]:    FOX
        [3]:    BROWN
        [4]:    jumps
        [5]:    over
        [6]:    the
        [7]:    lazy
        [8]:    dog
*/
Imports System.Collections

Public Class SamplesArrayList

   Public Class myReverserClass
      Implements IComparer

      ' Calls CaseInsensitiveComparer.Compare with the parameters reversed.
      Public Function Compare( ByVal x As Object, ByVal y As Object) As Integer _
         Implements IComparer.Compare
         Return New CaseInsensitiveComparer().Compare(y, x)
      End Function 'IComparer.Compare

   End Class

   Public Shared Sub Main()

      ' Creates and initializes a new ArrayList.
      Dim myAL As New ArrayList()
      myAL.Add("The")
      myAL.Add("QUICK")
      myAL.Add("BROWN")
      myAL.Add("FOX")
      myAL.Add("jumps")
      myAL.Add("over")
      myAL.Add("the")
      myAL.Add("lazy")
      myAL.Add("dog")

      ' Displays the values of the ArrayList.
      Console.WriteLine("The ArrayList initially contains the following values:")
      PrintIndexAndValues(myAL)

      ' Sorts the values of the ArrayList using the default comparer.
      myAL.Sort(1, 3, Nothing)
      Console.WriteLine("After sorting from index 1 to index 3 with the default comparer:")
      PrintIndexAndValues(myAL)

      ' Sorts the values of the ArrayList using the reverse case-insensitive comparer.
      Dim myComparer = New myReverserClass()
      myAL.Sort(1, 3, myComparer)
      Console.WriteLine("After sorting from index 1 to index 3 with the reverse case-insensitive comparer:")
      PrintIndexAndValues(myAL)

   End Sub

   Public Shared Sub PrintIndexAndValues(myList As IEnumerable)
      Dim i As Integer = 0
      Dim obj As [Object]
      For Each obj In  myList
         Console.WriteLine(vbTab + "[{0}]:" + vbTab + "{1}", i, obj)
         i = i + 1
      Next obj
      Console.WriteLine()
   End Sub

End Class


'This code produces the following output.
'The ArrayList initially contains the following values:
'        [0]:    The
'        [1]:    QUICK
'        [2]:    BROWN
'        [3]:    FOX
'        [4]:    jumps
'        [5]:    over
'        [6]:    the
'        [7]:    lazy
'        [8]:    dog
'
'After sorting from index 1 to index 3 with the default comparer:
'        [0]:    The
'        [1]:    BROWN
'        [2]:    FOX
'        [3]:    QUICK
'        [4]:    jumps
'        [5]:    over
'        [6]:    the
'        [7]:    lazy
'        [8]:    dog
'
'After sorting from index 1 to index 3 with the reverse case-insensitive comparer:
'        [0]:    The
'        [1]:    QUICK
'        [2]:    FOX
'        [3]:    BROWN
'        [4]:    jumps
'        [5]:    over
'        [6]:    the
'        [7]:    lazy
'        [8]:    dog

설명

가 로 null설정된 경우 comparer 이 메서드는 비교 정렬(불안정한 정렬이라고도 함)을 수행합니다. 즉, 두 요소가 같으면 순서가 유지되지 않을 수 있습니다. 반면, 안정적인 정렬은 같은 요소의 순서를 유지합니다. 안정적인 정렬을 수행하려면 사용자 지정 IComparer 인터페이스를 구현해야 합니다.

평균적으로 이 메서드는 연산입니다 O(n log n) . 여기서 n 는 이 count고, 최악의 경우 연산입니다 O(n^2) .

추가 정보

적용 대상