WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Numbers

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

UDF to Sort a Numeric List

Keywords:   UDF to Sort a Numeric List  ItemNumSort

#DefineFunction ItemNumSort(list,delim)
array=Arrayize(list,delim)
newlist=""
count=ArrInfo(array,1)-1
countm1=count-1
for xx=0 to countm1
   for yy=xx+1 to count
     if array[xx]>array[yy]
        t=array[xx]
        array[xx]=array[yy]
        array[yy]=t
     endif
   next
next

newlist=array[0]
for xx=1 to count
   newlist=strcat(newlist,delim,array[xx])
next
return (newlist)

#EndFunction

numlist = "8,1,2,3,4,5,-1,6,7,8,9,10,11,12,13,14,15,3"
sortlist=ItemNumSort(numlist,",")

message("Debug", strreplace(sortlist,",",@crlf))



Article ID:   W15760
File Created: 2003:05:13:11:29:56
Last Updated: 2003:05:13:11:29:56