recordset | The set of sorted records. This may be the name of a dataset or a record set derived from some filter condition, or any expression that results in a derived record set. |
value | A comma-delimited list of expressions or key fields in the recordset on which the recordset has been sorted, with the leftmost being the most significant sort criteria. A leading minus sign (-) indicates a descending-order sort on that element. You may have multiple value parameters to indicate sorts within sorts. You may use the keyword RECORD to indicate an ascending sort on all fields, and/or you may use the keyword EXCEPT to list non-sort fields in the recordset. |
index | The attribute name of an INDEX definition. This is equivalent to adding the SORTED option to the INDEX definition. |
Return: | SORTED is a compiler directive that returns nothing. |
The SORTED function indicates to the ECL compiler that the recordset is already sorted according to the values specified. Any number of value parameters may be supplied, with the leftmost being the most significant sort criteria. A leading minus sign (-) on any value parameter indicates a descending sort for that one parameter. SORTED typically refers to a DATASET to indicate the order in which the data is already sorted.
Example:
InputRec := RECORD
INTEGER4 Attr1;
STRING20 Attr2;
INTEGER8 Cid;
END;
MyFile := DATASET('filename',InputRec,FLAT)
MySortedFile := SORTED(MyFile,MyFile.Cid)
// Input file already sorted by Cid