Subscribe to Windows IT Pro
April 04, 2008 12:00 AM

VBSort.wsc to the Rescue: VBScript No Longer Lacks an Array Sorting Method

Windows IT Pro
InstantDoc ID #98792
Rating: (2)

Sorting an array is a common scripting task, but VBScript doesn't provide a native capability to do so. To fill this gap, Bill Stewart has written VBSort.wsc. This Windows script component implements the Penton.VBSort object, which provides three properties and a method that let you quickly sort VBScript arrays.

Bill discusses how to register and use VBSort.wsc in "Sorting Arrays in VBScript". He also presents a script, Sorter.vbs, that uses VBSort.wsc in "Using the Penton.VBSort Object to Sort Arrays". You can use Sorter.vbs to sort data in one file, then write the sorted data to another file. You can also use it to sort redirected lines of text. I opened up both articles for public viewing through May 1. If you enjoy reading these articles, you can get more of this type of content by subscribing to Scripting Pro VIP.

Related Content:

ARTICLE TOOLS

Comments
  • Bill
    4 years ago
    Sep 11, 2008

    Hi mikewell,

    Your list is sorted alphabetically and so the algorithm is working correctly. To sort numerically, you could try importing your list into a spreadsheet.

    Bill

  • Mike
    4 years ago
    Sep 10, 2008

    I tried sorting a number of IP addresses and found a flaw. (see below) Unfortunately I can't offer a solution at this time.

    172.25.1.1
    172.25.1.10
    172.25.1.100
    172.25.1.109
    172.25.1.11
    172.25.1.110
    172.25.1.119
    172.25.1.12

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.