我有一个数组,我通过引用传递给一个函数来对其进行排序。但是,似乎数组是按val传递的。任何人都可以解决什么问题?(也接受排序解决方法)
1) 下面的脚本通过引用传递一个数组到排序函数。
2) 排序函数输出排序后的数组值。
3) 脚本输出排序后的数组值。但是,它们没有排序。
脚本输出:
300,200,100,,
100,200,300,
'declare variables
mitta(1) = 1
mitta(2) = 2
mitta(3) = 3
sort(mitta) ' see the function below
' show variables
For i = 1 To 3
response.write mitta(i) & ","
next
' sort function
function sort(byref a)
dim num,i,j,temp
num = ubound(a)+1
For i = 0 To num - 1
For j = i + 1 To num - 1
If a(i) < a(j) Then
temp = a(i)
a(i) = a(j)
a(j) = temp
End If
Next
Next
' show sorted variables
For i = 0 To num - 1
response.write a(i) & ","
a(i) = 0
next
end function