b = sort(group using [-]item [where condition]);
The sort function will sort occurrences of records or items based on the value of an item. It will order the multiple records or items in the specified group in ascending sequence using the specified data item as the sort key. The sort key item must be contained within the record or item sorted. If a dash (negative sign) is included before the item name, the sort will be in descending order. If a where condition is included, the function sorts only the occurrences for which the condition is true.
Sort is primarily intended for use in batch applications. It should be used with extreme caution in data entry applications because of possible conflicts between the operator's actions and the program logic.
The function returns a logical value 1 (true) if successful and 0 (false) otherwise.
sort(PERSON using LINE_NUM);
// sort the children by age from oldest to youngest
sort(PERSON using -AGE where RELATIONSHIP = 3);
See also: Swap Function