SORT-MERGE/XL General User's Guide (32650-90883)

34 Chapter3
Using SORT/XL Interactively
Multiple Key Alphabetical Sorting
Multiple Key Alphabetical Sorting
You can designate multiple key data items to break sorting ties. This prevents the
situation described in the "Single Key Alphabetical Sorting" section above, where there
were three ANDERSON entries in the file. Issue the following commands to designate
multiple keys for the file EMPLOYEE. Only the three lines of the file listing the ANDERSON
entries are shown:
:SORT
HP32214A.01.00 SORT/3000 WED, JUN 3, 1987, 8:28 AM
© HEWLETT-PACKARD CO. 1986
>INPUT EMPLOYEE
>OUTPUT COMPANY
>KEY 1, 11
>KEY 12, 11
>END
PURGE OLD OUTPUT FILE COMPANY.GROUP.ACCOUNT ? Y
<<The SORT Statistics Appear Here>>
:EDITOR
HP32201A.07.17 EDIT/3000 WED, JUN 3, 1987, 8:29 AM
© HEWLETT-PACKARD CO. 1985
/TEXT COMPANY
FILE UNNUMBERED
/LIST 1/3
1 2 3 4
123456789012345678901234567890123456789012345
1 ANDERSON CHARLES SALES REP 3456
2 ANDERSON CHARLES PRESIDENT 0247
3 ANDERSON MARY ACCOUNTANT 6345
The two entries for CHARLES ANDERSON now appear before MARY ANDERSON in the list.
However, for the sort to be completely alphabetized the job title also needs to be
considered. To accomplish this you would designate three key data items with the >KEY
command.
To designate three key data items for last name, first name, and job title, enter the
following sequence of commands:
:SORT
HP32214A.01.00 SORT/3000 WED, JUN 3, 1987, 8:30 AM
© HEWLETT-PACKARD CO. 1986