This command will sort an array of fields in ascending or descending order. You can combine sort fields and can also move associated fields, even though they aren't part of the sort field.
|SORTA fn/v/e||Required - The field to be sorted. This can also be an expression containing several fields. The counter_field must be used as the array element specifier in the field or expression. For example:|
|NUM f/c/e||Required - The number of elements to sort. The actual maximum number of array elements must be at least number_of_elements+1.|
MOVE fn/v1, fn/v2,..., fn/vx Required - A list of array fields to be moved along with the field to be sorted. You must include at least the sort field itself. You may also include any other array fields that you want to be ordered in the same fashion as the sort field. The counter_field MUST NOT be specified as the array element in these fields. For example:
cust_state, cust_zip ,cust_sales, etc...
NOTE: This is a command change from previous versions of TAS Professional. If your array doesn't sort properly, check this first.
|CNTR fn/v||Required - This is the field that you will use in the command as the array specifier. It must be of type I.|
|which_way_to_sort||ASC / DSC - Use ASC for ascending (names and numbers get larger as the array element number increases) or DSC for descending (names and numbers get smaller as array element number increases).|
define MfgStrtDate type D size 8 array 100
define MfgGroup type I size 3 array 100
define MfgQty type N size 6 array 100
If you use the following code the sort adds the items instead of treating them independently.
Will not sort correctly.
sorta MfgGroup[aCntr] + MfgStrtDate[aCntr] num aCntr move MfgGroup,MfgStrtDate,MfgQty cntr aCntr dsc
This will sort correctly. use the str() function in this command.
sorta str(MfgGroup[aCntr]) + dtos(MfgStrtDate[aCntr]) num aCntr move MfgGroup,MfgStrtDate,MfgQty cntr aCntr dsc
To effect proper sort you may need to use dtos() for dates or ttos for time. You may also if using a time fld convert this to a record??