uses generics 'containing sort macros
uses console
string sdata={"CC","Aa","aAa","bb","bbB","b","B","c","A"}
'
int count = countof sdata
'
macro filter(f,a)
=================
  'sdata[a]
  f=1 'allow all
end macro
'
macro compare(f,a,b)
====================
  int la=len sdata[a]
  int lb=len sdata[b]
  if la<lb
    f=1 'descending length
  elseif la>lb
    '
  elseif ucase(sdata[a])>ucase(sdata[b])
    f=1 'ascending but case insensitive
  endif
end macro
'
NewSortIndex(index,count,rcount,filter,compare)
NewSortedData(sorted,sdata,index,rcount)
'
print "Count: " rcount cr cr
int i
for i=1 to rcount
  print sorted[i] cr
next
pause
   