欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

数组数据排序的程序例子

程序员文章站 2022-05-09 20:54:58
数组数据排序的程序例子 <% *** build example array to show that this thing can sort *** alpha-numer...
数组数据排序的程序例子



<%
*** build example array to show that this thing can sort
*** alpha-numeric arrays
dim myarray
myarray = array(1,5,"shawn","says","hello"2m骺噃嶤123,12,98)
myarray = sort(myarray)
for i = 0 to ubound(myarray)
response.write myarray(i) & "<br>" & vbcrlf
next
response.end


*** sorter function that takes an array and sorts it
function sort(ary)
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)
secondvalue = ary(i+1)
ary(i) = secondvalue
ary(i+1) = firstvalue
keepchecking = true
end if
next
loop
sort = ary
end function
%>