Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 1st, 2006, 9:03 AM   #1
randum77
Programmer
 
randum77's Avatar
 
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3 randum77 is on a distinguished road
VBScript - Sorting

In VBScript can the Array.Sort method be used? If not, do i have to build a loop to do the work? If that ends up being the case, how would I build a loop to do that? Just basic guidence would be cool.
__________________
_Marshall_

"America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt."
randum77 is offline   Reply With Quote
Old Aug 1st, 2006, 1:27 PM   #2
melbolt
Professional Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 253
Rep Power: 4 melbolt is on a distinguished road
vbscript lacks a sort function for arrays.

what can you do? here are your options, i recommend #1
1) use Javascript to sort an array for you. you can call a javascript function from within your vbscript like so

<script language=JScript runat=server>
function SortVBArray(arrVBArray) {
return arrVBArray.toArray().sort().join('\b');
}
</script>

<%
Function SortArray(arrInput)
SortArray = Split(SortVBArray(arrInput), Chr(8))
End Function
%>

here's some more helpful stuff at this link
http://www.4guysfromrolla.com/aspfaq...Q.asp?FAQID=89

2)build your own - this works too but you're reinventing the wheel

3) use one someone else built in vbscript, a google search will turn this up, this works too.
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote
Old Aug 2nd, 2006, 8:17 AM   #3
randum77
Programmer
 
randum77's Avatar
 
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3 randum77 is on a distinguished road
Melbolt, thank you for the info. What i ended up doing was using one that i found on a page, and just modified it to fit my needs. Let me show you what I used. I hate the variables used, but i eventually figured it out.

 for i = 0 to ln - 1
    for j = i + 1 to ln
        if (fa(i,2) < fa(j,2)) then 'fa(i,0) = fa(j,0) and 
            sn = fa(i,0)
            s = fa(i,1)
            fd = fa(i,2)
	  mn = fa(i,3)
            fa(i,0) = fa(j,0)
            fa(i,1) = fa(j,1)
            fa(i,2) = fa(j,2)
	  fa(i,3) = fa(j,3)
            fa(j,0) = sn
            fa(j,1) = s
            fa(j,2) = fd
	  fa(j,3) = mn
         end if
    next

I cut and commented out the spare code. It bassically just sorts by the 3rd feild in the array, which is the second column. It works pretty good for what we were needing here at work.

I do like that java insert idea though. I'll have to take advantage of that here soon.
__________________
_Marshall_

"America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt."
randum77 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting taporctv Java 9 Apr 15th, 2006 9:55 AM
Sorting bug Cabochon C 10 Mar 25th, 2006 9:02 AM
Sorting a Numeric Array little_valaree Java 2 Nov 21st, 2005 12:00 PM
Convert VBA to VBScript seanhepburn2002 Visual Basic 2 Oct 15th, 2005 5:20 PM
VBScript and ASP java_roshan ASP 3 Oct 3rd, 2005 2:27 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:43 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC