paramArr(0,0) = "method"
paramArr(0,1) = "taobao.taobaoke.items.get"
paramArr(1,0) = "timestamp"
paramArr(1,1) = Format_Time(now(),1)
paramArr(2,0) = "format"
paramArr(2,1) = "xml"
有上述二维数组
想实现按paramArr(x,1)排序,要实现排列后的结果如下:
paramArr(0,0) = "format"
paramArr(0,1) = "xml"
paramArr(1,0) = "method"
paramArr(1,1) = "taobao.taobaoke.items.get"
paramArr(2,0) = "timestamp"
paramArr(2,1) = Format_Time(now(),1)
f、m、t这样按字母升序排列
目前只知道PHP中可以通过ksort实现排序...
希望高手能提供相应ASP或VB的function,谢谢
大哥,这样排列出来顺序不对啊...
另外,我需要对一个未知个数的二维数组进行排序
二维数组按字母排序
答案:4 悬赏:50 手机版
解决时间 2021-12-30 12:17
- 提问者网友:蓝琪梦莎
- 2021-12-30 03:59
最佳答案
- 五星知识达人网友:迷人又混蛋
- 2021-12-30 04:51
paramArr(x,0)升序?paramArr(x,1)降序?试试(注意sort中的a数据类型必须与paramarr保持一致,sort对长度不定的二维数组都是可以处理的):
Private Sub Command1_Click()
Dim paramarr(0 To 2, 0 To 1)
paramarr(0, 0) = "method"
paramarr(0, 1) = "taobao.taobaoke.items.get"
paramarr(1, 0) = "timestamp"
paramarr(1, 1) = Format_Time(Now(), 1)
paramarr(2, 0) = "format"
paramarr(2, 1) = "xml"
Sort paramarr
For i = 0 To 2
For j = 0 To 1
Print paramarr(i, j)
Next
Next
End Sub
Private Sub Sort(a())
Dim i, j, t
For i = LBound(a, 1) To UBound(a, 1) - 1
For j = i + 1 To UBound(a, 1)
If a(i, 0) > a(j, 0) Then '升序
t = a(i, 0): a(i, 0) = a(j, 0): a(j, 0) = t
End If
If a(i, 1) < a(j, 1) Then '降序
t = a(i, 1): a(i, 1) = a(j, 1): a(j, 1) = t
End If
Next j
Next i
End Sub
Private Sub Command1_Click()
Dim paramarr(0 To 2, 0 To 1)
paramarr(0, 0) = "method"
paramarr(0, 1) = "taobao.taobaoke.items.get"
paramarr(1, 0) = "timestamp"
paramarr(1, 1) = Format_Time(Now(), 1)
paramarr(2, 0) = "format"
paramarr(2, 1) = "xml"
Sort paramarr
For i = 0 To 2
For j = 0 To 1
Print paramarr(i, j)
Next
Next
End Sub
Private Sub Sort(a())
Dim i, j, t
For i = LBound(a, 1) To UBound(a, 1) - 1
For j = i + 1 To UBound(a, 1)
If a(i, 0) > a(j, 0) Then '升序
t = a(i, 0): a(i, 0) = a(j, 0): a(j, 0) = t
End If
If a(i, 1) < a(j, 1) Then '降序
t = a(i, 1): a(i, 1) = a(j, 1): a(j, 1) = t
End If
Next j
Next i
End Sub
全部回答
- 1楼网友:西岸风
- 2021-12-30 08:27
Dim i, j, k
For i = 0 To UBound(paramArr, 1) - 1
For j = i + 1 To UBound(paramArr, 1)
If paramArr(i, 0) > paramArr(j, 0) Then
For k = 0 To UBound(paramArr, 2)
Dim tmp
tmp = paramArr(i, k)
paramArr(i, k) = paramArr(j, k)
paramArr(j, k) = tmp
Next
End If
Next
Next
- 2楼网友:渊鱼
- 2021-12-30 07:57
StrComp StrComp(string1,string2[,compare]) 返回string1字符串与string2字符串的比较结果,如果两个字符串相同,则返回0,如果小于则返回-1,如果大于则返回1
- 3楼网友:第四晚心情
- 2021-12-30 06:23
有个投机取巧的方法。。。就是把LISTBOX控件的SORT值设为TRUE,然后把数组加载进去,最后再又上到下再加载回数组。。。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯