## Re: Can you return the names of the form elements?

> "Ray at <%=sLocation%>" wrote ...
>
>> Note that these fields will not be returned in any controllable
>> order.
>
> Cheers Ray thats grand...
>
> Know of anyway to sort an array? :)
>
> Robb
One way is to use a bubble sort, which will give acceptable performance on
small (>100) data sets.

dim ar, i , j, vTemp
ar=array(dog,cat,bird,monkey)
response.write "Before Sort:<BR>"
for i = 0 to ubound(ar)
response.write ar(i) & "<BR>"
next
for i=0 to ubound(ar)-1
for j = i+1 to ubound(ar)
if ar(j) <= ar(i) then
vTemp = ar(j)
ar(j) = ar(i)
ar(i) = vTemp
end if
next
next
response.write "After Sort:<BR>"
for i = 0 to ubound(ar)
response.write ar(i) & "<BR>"
next

To sort numbers, change "if ar(j) <= ar(i) then" to "if cdbl(ar(j)) <=
cdbl(ar(i)) then", or cint, clng, etc., depending on what type of numbers
you are sorting.

Another way is to use an ad hoc recordset:

dim ar, i , rs
ar=array(dog,cat,bird,monkey)
response.write "Before Sort:<BR>"
for i = 0 to ubound(ar)
response.write ar(i) & "<BR>"
next
'again, use the datatype that makes sense for your data
rs.open
for i = 0 to ubound(ar)
next
rs.sort "data"
i=0
do until rs.eof
ar(i) = rs(0)
i=i+1
loop
rs.close
set rs=nothing
response.write "After Sort:<BR>"
for i = 0 to ubound(ar)
response.write ar(i) & "<BR>"
next

HTH,
Bob Barrows