ArrayListオブジェクトの要素をソートします。
構文
Object.Sort()
引数 - 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"