Dim i, int1(3), str1(3), s
int1(0) = 22
int1(1) = 14
int1(2) = 6
int1(3) = 13
Call sortFigu(int1)'调用过程进行处理
For i = LBound(int1) To UBound(int1)
s = s & CStr(int1(i)) & " "
Next
MsgBox s'显示int1排序后的结果
str1(0) = "d"
str1(1) = "a"
str1(2) = "j"
str1(3) = "b"
Call sorString(str1)'调用过程进行处理
s = ""
For i = LBound(str1) To UBound(str1)
s = s & CStr(str1(i)) & " "
Next
MsgBox s'显示str1排序后的结果
Private Sub sortFigu(ByRef int1)'数字数组升序排序
Dim i, j, temp
For i = LBound(int1) To UBound(int1)
For j = i To UBound(int1)
If int1(i) > int1(j) Then
temp = int1(i)
int1(i) = int1(j)
int1(j) = temp
End If
Next
Next
End Sub
Private Sub sorString(ByRef str1)'字符数组降序排序
Dim i, j,temp
For i = LBound(str1) To UBound(str1)
For j = i To UBound(str1)
If str1(i) < str1(j) Then
temp = str1(i)
str1(i) = str1(j)
str1(j) = temp
End If
Next
Next
End Sub
'以上只是个演示,里面的两个过程你可以放到你的网页中调用
将json里的uname取出来放进数组,然后直接用sort函数排序。这种格式的json数据是服务器返回的我需要用在小程序里用JS处理默认按uname的首字母排序并且分组,而且还有搜索功能。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)