Sorting numbers

1. Senior Member
Join Date
Dec 1969
Posts
106

## Sorting numbers

I am having great difficultly trying to do the most simplist thing. How do I sort numbers (desc) in an array? I have read the FAQs re sorting arrays and tried everything to make this work but it just won&#039;t work. Thanks for your help.<BR><BR>&#060;html&#062;<BR>&#060;script language=JScript runat=server&#062;<BR> function SortVBArray(arrVBArray) {<BR> return arrVBArray.toArray().sort().join(&#039;&#039;);<B R> }<BR>&#060;/script&#062;<BR>&#060;%<BR> Function SortArray(arrInput)<BR> SortArray = Split(SortVBArray(arrInput), Chr(8))<BR> End Function<BR><BR>numbers=array(12,53,23)<BR><BR>&#0 39;---this is where I get screwed up----?<BR>response.write SortVBArray(numbers)<BR><BR>%&#062;<BR>&#060;/html&#062;<BR>

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Nothing to do with sorting

You aren&#039;t following directions.<BR><BR>You are calling the SortVBArray function instead of the SortArray function.<BR><BR>You *can* do that, but when you do you get back a *string* that has funny delimiters between the values and certainly *not* an array.<BR><BR>Follow the directions:<BR><BR>&#060;%<BR>...<BR>numbers = SortArray( numbers )<BR>For i = 0 To UBound( numbers )<BR>&nbsp; &nbsp; Response.Write "#" & i & " is " & numbers(i) & "&lt;BR&#062;"<BR>Next<BR>%&#062;<BR>

3. Senior Member
Join Date
Dec 1969
Posts
106

## RE: Nothing to do with sorting

aaahhh,<BR><BR>Actually I did try that but I was missing to loop piece.<BR><BR>Thank you!!!<BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•