VBScript - Sort question

Gearhead7

Member
Joined
Jul 17, 2006
Messages
10
Programming Experience
Beginner
I could not find a forum specifically for VBScripting. Can you use a Array.Sort method in VBScript or do you have to build a manual system for sorting? If so, where the heck would I start? :confused: Thanks in advance.
 

kulrom

Well-known member
Joined
May 10, 2005
Messages
2,854
Location
Republic of Macedonia
Programming Experience
10+
Ok althrough VBScript is not targeted language of this forum again it is a little bro of the vb as well of VB.NET :D
means to sort an array of values, nothing special needs to be done:
For example, say you have an array like this one:
VB.NET:
dim myArray
myArray = Array(3,1,8,2,4)
Then in order to sort this array you should do this:
VB.NET:
dim sort
set sort = new QSort
sort.Sort myArray

if you want to output the array you can do something like this:

VB.NET:
dim i
for i = 0 to UBound(myArray)
   if (i > 0) then Response.Write ","
   Response.Write myArray(i)
next
and the output will look like this:
VB.NET:
1,2,3,4,8

HTH
Regards ;)
 

Gearhead7

Member
Joined
Jul 17, 2006
Messages
10
Programming Experience
Beginner
Kulrom, thanks for the info. I'll use this to make a sort that works right. It makes alot more sense when someone can explain it to you. :)
 
Top Bottom