asp下实现 重新排序数字数组的代码
程序员文章站
2023-08-24 11:55:47
<% '****************************** '函数:neworder(arrstr) '参数:rstr,以逗号做分隔的数字数组 '作者:阿里...
<%
'******************************
'函数:neworder(arrstr)
'参数:rstr,以逗号做分隔的数字数组
'作者:阿里西西
'日期:2007/7/13
'描述:重排序数字数组
'示例:<%=neworder("34,53,13,22,38,86,111,23,65")%>
'******************************
function neworder(arrstr)
for i = 0 to ubound(split(arrstr,","))
if n > 0 then
arrstr = replace(arrstr,n,0)
end if
sp = split(arrstr,",")
n = 0
for j = 0 to ubound(sp)
if int(sp(j)) > int(n) then
n = sp(j)
end if
next
neworder = neworder & replace(n,0,"") & " "
next
neworder = neworder
end function
%>
对数组进行重新排序
<%
'******************************
'函数:neworder(sz)
'参数:rstr,以逗号做分隔的数字数组
'作者:阿里西西
'日期:2007/7/13
'描述:对数组进行重新排序
'示例:<%=neworder("34,53,13,22,38,86,111,23,65")%>
'******************************
function neworder(sz)
dim ali,icount,i,ii,j,itemp
ali=split(sz,",")
icount=ubound(ali)
for i=0 to icount
for j=icount - 1 to i step -1
if j+1 <= ubound(ali) then
if int(ali(j))<int(ali(j+1)) then
itemp=ali(j)
ali(j)=ali(j+1)
ali(j+1)=itemp
end if
end if
next
next
for ii=0 to ubound(ali)
if ii = ubound(ali) then
neworder = neworder & ali(ii)
else
neworder = neworder & ali(ii) & ","
end if
next
end function
%>
'******************************
'函数:neworder(arrstr)
'参数:rstr,以逗号做分隔的数字数组
'作者:阿里西西
'日期:2007/7/13
'描述:重排序数字数组
'示例:<%=neworder("34,53,13,22,38,86,111,23,65")%>
'******************************
function neworder(arrstr)
for i = 0 to ubound(split(arrstr,","))
if n > 0 then
arrstr = replace(arrstr,n,0)
end if
sp = split(arrstr,",")
n = 0
for j = 0 to ubound(sp)
if int(sp(j)) > int(n) then
n = sp(j)
end if
next
neworder = neworder & replace(n,0,"") & " "
next
neworder = neworder
end function
%>
对数组进行重新排序
复制代码 代码如下:
<%
'******************************
'函数:neworder(sz)
'参数:rstr,以逗号做分隔的数字数组
'作者:阿里西西
'日期:2007/7/13
'描述:对数组进行重新排序
'示例:<%=neworder("34,53,13,22,38,86,111,23,65")%>
'******************************
function neworder(sz)
dim ali,icount,i,ii,j,itemp
ali=split(sz,",")
icount=ubound(ali)
for i=0 to icount
for j=icount - 1 to i step -1
if j+1 <= ubound(ali) then
if int(ali(j))<int(ali(j+1)) then
itemp=ali(j)
ali(j)=ali(j+1)
ali(j+1)=itemp
end if
end if
next
next
for ii=0 to ubound(ali)
if ii = ubound(ali) then
neworder = neworder & ali(ii)
else
neworder = neworder & ali(ii) & ","
end if
next
end function
%>