Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


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))