![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3
![]() |
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." |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
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 |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3
![]() |
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
nextI 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." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sorting | taporctv | Java | 9 | Apr 15th, 2006 8:55 AM |
| Sorting bug | Cabochon | C | 10 | Mar 25th, 2006 8:02 AM |
| Sorting a Numeric Array | little_valaree | Java | 2 | Nov 21st, 2005 11:00 AM |
| Convert VBA to VBScript | seanhepburn2002 | Visual Basic | 2 | Oct 15th, 2005 4:20 PM |
| VBScript and ASP | java_roshan | ASP | 3 | Oct 3rd, 2005 1:27 PM |