SRT( ) |
Sort String |
1. |
SRT(string$,fixed_len[,ERR=stmtref]) | |
2. |
SRT(string$[,dlm_char$][,ERR=stmtref]) |
dlm_char$ |
Delimiter for each string element. If omitted, the default delimiter is the SEP character (e.g. $8A$). |
fixed_len |
Numeric expression. Length of each element in the string (all the same fixed length). |
stmtref |
Program line number or statement label to which to transfer control. |
string$ |
String to be sorted. |
Sorted character string.
The SRT( ) function returns a sorted character string. The string elements are internally sorted into ascending sequence. The order of duplicate elements is undefined.
Sort Equal Length Elements
SRT(string$,fixed_len[,ERR=stmtref])
If each element in the string is the same fixed length, use this format to sort the string.
rem To sort in ascending order:
A$="0231405242670291234403242"
print srt(A$,5)
->run
0231403242052421234467029
rem To sort in descending order:
print not(srt(not(A$),5))
->run
6702912344052420324202314
Sort Delimited Elements
SRT(string$[,dlm_char$][,ERR=stmtref])
If each element in the string has a delimiter or SEP character, use this format to sort the string. PxPlus considers the first character of dlm_char$ to be your delimiter. The default is the current SEP value.
rem To sort with delimited strings:
A$="THE BROWN FOX JUMPED OVER THE DOG" ! Blank as delimiter, ends string
print srt(A$," ")
->run
BROWN DOG FOX JUMPED OVER THE THE