function PoP(ArrayStr)'ArrayStr为以逗号分隔的数字 Dim TempArray dim TempStr,tStr dim i,j,k,l dim Exchange'交换标记 TempArray=split(ArrayStr,",") for i=1 to ubound(TempArray)'最多进行n-1趟排序 ExChange=false for j=ubound(TempArray) to i step -1'对当前无序区R[i..n]自下向上扫描 if not isnumeric(TempArray(j)) then exit for if cint(TempArray(j))<Cint(TempArray(j-1)) then TempStr=TempArray(j) TempArray(j)=TempArray(j-1) TempArray(j-1)=TempStr ExChange=true 'Response.Write "第"&i&"趟 发现"&TempArray(j-1)&"比"&TempArray(j)&"小,将其位置调换
" end if next if ExChange=false then exit for next tStr="" for k=0 to ubound(TempArray) tStr=tStr&TempArray(k)&"," next Pop=mid(tStr,1,len(tStr)-1) end function
" end if next if ExChange=false then exit for next tStr="" for k=0 to ubound(TempArray) tStr=tStr&TempArray(k)&"," next Pop=mid(tStr,1,len(tStr)-1) end function