ddlSort() Examples
ddlSort Examples:
Suppose you isolate CUSTOMERS records and want to SORT the names in
alphabetical order and PRINT the names and ages.
CLEAR
A
FILL
A CUSTOMERS
SORT
A BY NAME
PRINT
A NAME AGE
You can sort by more than one field at a time:
SORT
A BY AGE CITY
PRINT
A NAME AGE CITY
produces a list of customers sorted first by their age. Within each age group,
the cities are sorted in ascending alphabetical order.
The order in which you list the field names to be sorted decides the precedence
of the sort.
If you change the above SORT command so that CITY comes first:
SORT
A BY CITY AGE
PRINT
A NAME AGE CITY
you get a list of customers where the primary sort is by CITY in alphabetical
order. Within cities, the ages are sorted in ascending order.
In the last command, if you want the ages to sort in descending order
(ascending is the default) you place a "D" before the AGE
SORT
A BY CITY D AGE
Caution! If you SORT globally, you should
PRINT (or Read) globally.
If you SORT specifically, you should PRINT (or Read) specifically.
For example:
FIND
A WHERE STATUS=OK
SORT
A CUSTOMERS BY AGE
PRINT
A CUSTOMERS NAME AGE
is a correct command sequence.
Suppose the SORT and PRINT are expressed this way:
SORT
A CUSTOMERS BY AGE
PRINT
A NAME AGE
the results display as unsorted. That's because it was A CUSTOMERS that was
sorted, and the PRINT was directed at just A.
Conversely, if you do the following:
SORT
A BY AGE
PRINT
A CUSTOMERS NAME AGE
the results display as unsorted. The SORT was directed at A and the PRINT was
directed at A CUSTOMERS.