XSSORT() Function




In BBj 3.0 and higher, the XSSORT() function sorts str1 using int1 as the record size and optionally using the key described using str2 and int2 as a key descriptor pair. The key descriptor has the length of the key to sort. The string returned by this function is str1, sorted.

See XKGEN() Function for additional information.


0010 erase "xkeyed.dat",err=*next
0020 xkeyed "xkeyed.dat",[1:1:1],[2:1:1],0,80
0030 xk=unt
0040 open (xk)"xkeyed.dat"
0050 fid$=fid(xk),fin$=fin(xk)
0060 xfid$=xfid(xk),xfin$=xfin(xk)
0070 recs$=""
0080 for rec=1 to 10
0090 f1$=chr(asc("A")+rec-1),f2$=str(rec),rec$=f1$+$0a$+f2$+$0a$
0100 write record (xk,dir=0)rec$
0110 readrecord(xk,dir=0)rec$
0120 k0$=kgen(rec$,fin$(86),0)
0130 xk0$=xkgen(rec$,xfin$(86),0)
0140 if k0$<>xk0$ then escape
0150 rem print k0$,":",xk0$
0160 k1$=kgen(rec$,fin$(86),1)
0170 xk1$=xkgen(rec$,xfin$(86),1)
0180 if k1$<>xk1$ then escape
0190 rem print k1$,":",xk1$
0200 recs$=rec$+recs$
0210 next rec
0220 print cvs(xssort(recs$,80,xfin$(86),0),16)
0230 end

See Also

Functions - Alphabetical Listing