求教asp数组排序问题

maxcn 2008-03-24 07:05:29
求教高手个asp数组排序问题

我有两个数组要重新排序请教高手个排序方法

例如 数组一 1,2,3,4,5,6,
数组二 A,B,C,D,E,F,
排序结果 新数组 数组三 1A,2B,3C,4D,5E,6F

这个排序方式不知道咋搞好,特来请教承蒙各位赐教
...全文
75 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
maxcn 2008-03-24
谢谢各位兄弟,明白原理了,非常感谢
回复
myvicy 2008-03-24
发一个vb可用的直接排序数组的函数.
Function Sort(ary)
Dim KeepChecking,I,FirstValue,SecondValue
KeepChecking = TRUE
Do Until KeepChecking = FALSE
KeepChecking = FALSE
For I = 0 to UBound(ary)
If I = UBound(ary) Then Exit For
If ary(I) > ary(I+1) Then
FirstValue = ary(I)
ary(I) = ary(I+1)
ary(I+1) = FirstValue
KeepChecking = TRUE
End If
Next
Loop
Sort = ary
End Function
回复
hookee 2008-03-24
如果机器上装过.Net运行时的话,更简单点也可以:

<%
a = Array(1,2,3,4,5)
b = Array("A","B","C","D","F")

Set lista = CreateObject("System.Collections.ArrayList")
For i=0 To UBound(a)
lista.Add a(i)
Next
lista.Sort
Set listb = CreateObject("System.Collections.ArrayList")
For i=0 To UBound(b)
listb.Add b(i)
Next
listb.Sort

Dim c
ReDim c(UBound(a))
For i=0 To UBound(a)
c(i) = lista.Item(i) & listb.Item(i)
Next

For i=0 To UBound(c)
Response.Write c(i)
Next

%>
回复
hookee 2008-03-24

<%
a = Array(1,2,3,4,5)
b = Array("A","B","C","D","F")

Set rs = CreateObject("ADODB.RecordSet")
rs.cursorLocation = 3
rs.Fields.Append "num",3,4
rs.Open
For i=0 To UBound(a)
rs.AddNew
rs("num").value = a(i)
Next
rs.sort = "num ASC"
rs.MoveFirst

Set rs1 = CreateObject("ADODB.RecordSet")
rs1.cursorLocation = 3
rs1.Fields.Append "str",200,50
rs1.Open
For i=0 To UBound(b)
rs1.AddNew
rs1("str").value = b(i)
Next
rs1.sort = "str ASC"
rs1.MoveFirst

Dim c
ReDim c(UBound(a))
i=0
Do While Not rs.eof
c(i) = rs("num") & rs1("str")
rs.MoveNext
rs1.MoveNext
i = i+1
Loop

For i=0 To UBound(c)
Response.Write c(i)
Next

%>

回复
myvicy 2008-03-24
直接按顺序写就可以了吧。
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-03-24 07:05
社区公告
暂无公告