Sort 메소드

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

구문

Object.Sort()

Arguments - Object: 필수 항상 ArrayList 객체의 이름입니다.

주석

요소는 정렬 후 오름차순으로 표시됩니다.

다음 예에서는 Sort 메소드의 사용을 보여 줍니다.

예 1:

'Create ArrayList Object
Dim Obj
Set Obj = CreateObject("System.Collections.ArrayList")

'Add Elements to the end of ArrayList Object
Dim Index
Index = Obj.Add(10)
Index = Obj.Add(40)
Index = Obj.Add(20)
Index = Obj.Add(30)

'Sorts the elements in the ArrayList object.
Obj.Sort()
'Output: Obj contains 10, 20, 30, 40

예 2:

'Create ArrayList Object
Dim Obj
Set Obj = CreateObject("System.Collections.ArrayList")

'Add Elements to the end of ArrayList Object
Dim Index
Index = Obj.Add("Banana")
Index = Obj.Add("Grapes")
Index = Obj.Add("Apple")
Index = Obj.Add("ButterFruit")

'Sorts the elements in the ArrayList object.
Obj.Sort()
'Output: Obj contains "Apple", "Banana", "ButterFruit", "Grapes"