1.

Solve : vbscript sorting?

Answer»

how to sort an arrays without using bubble sort?
thanks for helping.
http://www.vbforums.com/showthread.php?t=473677

This is for VB6, not VBScript, but it can be easily modified.If you have the .Net FRAMEWORK installed you can use the ArrayList class and keep your typing to a minimum.

Code: [Select]Set DataList = CreateObject("System.Collections.ArrayList")

DataList.Add "B"
DataList.Add "C"
DataList.Add "E"
DataList.Add "D"
DataList.Add "A"

DataList.Sort()

For Each strItem in DataList
Wscript.Echo strItem
Next

Save script with a VBS extension and run from the command line as cscript scriptname.vbs

You can also use a Disconnected Recordset, but because there is no underlying database, all the fields must be defined in the script. One advantage is that MULTIPLE fields can be sorted in MIXED sort order (ascending/descending)

GOOD LUCK.



Discussion

No Comment Found