Description:
Sort a bin file or a sequence of bin files and generate a new bin file.
Syntax:
f.sortx(Fi,…;fn) |
Sort a bin file according to field Fi and generate a new bin file |
[fi,…].sortx(Fi,…;fn) |
Sort a sequence of bin files according to field Fi and generate a new bin file; perform a simple concatenation when parameter Fi is absent |
Note:
The function sorts bin file f or a sequence of bin files [fi,…] by certain field Fi , generates a new bin file fn and return non-null if the operation succeeds.
Parameter:
f |
A bin file object |
[fi,…] |
A sequence of bin files of same structure |
Fi |
Name(s) of f field(s) by which the file is sorted |
fn |
Bin file object(s); generate a temporary file and return its cursor when this parameter is absent |
Option:
@z |
Sort in descending order; default is ascending |
Return value:
Boolean/cursor
Example:
Sort a bin file:
|
A |
|
1 |
=file("PERFORMANCE.btx") |
A bin file object; its content is as follows:
|
2 |
=file("PER-cp.btx") |
Specify a bin file object. |
3 |
=A1.sortx(BONUS;A2) |
Sort PERFORMANCE.btx by BONUS field and generate a new bin file PER-cp.btx, whose content is as follows:
|
4 |
=A1.sortx(BONUS) |
As parameter fn is absent, generate a temporary file in the temporary directory and return a cursor, whose content is same as that in A3. |
5 |
=A1.sortx@z(BONUS) |
Sort by BONUS field in descending order and return a cursor whose content is as follows:
|
Sort a sequence of bin files:
|
A |
|
1 |
=file("f_emp.btx") |
A bin file object; its content is as follows:
|
2 |
=file("m_emp.btx") |
A bin file object; its content is as follows:
|
3 |
=file("emp_all.btx") |
|
4 |
=[A1,A2].sortx(SALARY,EID;A3) |
Sort f_emp.btx and m_emp.btx by SALARY and EID fields and generate a new bin file emp_all.btx, whose content is as follows:
|
5 |
=[A1,A2].sortx(SALARY) |
As parameter fn is absent, return a cursor. |
Perform a simple concatenation on a sequence of bine files when parameter Fi is absent:
|
A |
|
1 |
=file("f_emp.btx") |
A bin file object whose content is as follows:
|
2 |
=file("m_emp.btx") |
A bin file object whose content is as follows:
|
3 |
=file("emp_gb.btx") |
|
4 |
=[A1,A2].sortx(;A3) |
Concatenate f_emp.btx and m_emp.btx and generate a new bin file emp_gb.btx whose content is as follows:
|