◆数组排序问题
假如现有数组按“/”分:
002;bb;/001;aa;/003;cc;/001;bb;/
现在需要把它变成按原先数组第一个字母进行重新排序,
并且去掉第一个分号前重复的数组生成如下:
001;aa;/002;bb;/003;cc;/
其中:第四个001;bb;因为第一个分号与001相等同,所以去掉。
以下是一位师兄写的代码,但目前只能实现排序,即变为这样:
001;aa;/001;bb/002;bb;/003;cc;/
那位高手再帮忙修改下,不然过年我真的回不去了。。55
谢谢。。
<%
str="002;bb;/001;aa;/003;cc;/"
tmp=""
tmp1=split(str,"/")
for k=0 to ubound(tmp1)
for i=0 to ubound(tmp1)-1
if (tmp1(i))>= (tmp1(i+1)) then
'如果这里为>则是从小到排,如果是<则是从大到小排
tmp=tmp1(i+1)
tmp1(i+1)=tmp1(i)
tmp1(i)=tmp
end if
next
next
str1=""
for j=0 to ubound(tmp1)
str1=str1&tmp1(j)&"/"
next
str1=right(str1,len(str1)-1)
response.write ("原字串为:" & str & "<br>从小到大:" & str1)
%>