VBScript lacks the native capability to sort an array, which is why I created a Windows Script Component (WSC) named VBSort.wsc. As I described in "Sorting Arrays in VBScript" (April 2006, InstantDoc ID 49458), the main object in this WSC is Penton.VBSort. Let's explore how to use this object by looking at a script named Sorter.vbs. This script uses Penton.VBSort to sort data in one file and write it to another file. Because Sorter.vbs supports both standard input and standard output, you can also use it to sort redirected lines of text.
Using Sorter.vbs
Sorter.vbs requires the Penton.VBSort object, so you must register VBSort.wsc
on your computer before you run the script. Sorter.vbs also requires the CScript
host.
To launch Sorter.vbs, you follow the command-line syntax
[cscript] Sorter.vbs [filename]
[/o:outputfile] [/d] [/i] [/r]
You include the cscript keyword at the beginning of the command when CScript
isn't your default host (more on this shortly). The filename argument
specifies the file to be sorted. The script reads all the lines from this input
file into an array, then uses the Penton.VBSort object's Sort method to sort
the array. If you don't specify an input file, Sorter.vbs sorts the lines from
standard input. . . .