HPlogo SORT-MERGE/XL General User's Guide > Chapter 3 Using SORT/XL Interactively

Sorting Numerically

MPE documents

Complete PDF
Table of Contents
Index
Glossary

The last column of data in the file EMPLOYEE lists employee numbers. These were assigned chronologically to each new employee. To obtain a list of all employees in the order of their hiring you would proceed as shown in the following example:

  :SORT

  HP32214A.01.00  SORT/3000 WED, JUN  3, 1987,  8:35 AM
  (C) HEWLETT-PACKARD CO. 1986

  >INPUT EMPLOYEE
  >OUTPUT COMPANY
  >KEY 42, 4
  >END
  PURGE OLDOUTPUT FILE COMPANY.GROUP.ACCOUNT ? Y

     <<The SORT Statistics Appear Here>>

  :EDITOR
  HP32201A.07.17 EDIT/3000 WED, JUN  3, 1987,  8:40 AM
  (C) HEWLETT-PACKARD CO. 1985
  /TEXT COMPANY
   FILE UNNUMBERED
  /LIST ALL
                 1         2         3         4
        123456789012345678901234567890123456789012345

   1    ANDERSON   CHARLES    PRESIDENT          0247
   2    LANGE      ROBERT     ENGINEER           3235
   3    ANDERSON   CHARLES    SALES REP          3456
   4    CARLSON    ROBERTA    TREASURER          3586
   5    ZIMMER     ANDREW     ENGINEER           5739
   6    ANDERSON   MARY       ACCOUNTANT         6345
   7    SMITH      HOWARD     DESIGNER           6794
   8    TAYLOR     HEATHER    SECRETARY          7272
   9    FISHER     TOM        SHIPPING CLERK     7309
  10    JOHNSON    FRANCES    RECEPTIONIST       7943

To determine the newest employee, and obtain a list in descending order to the one with the most seniority, use the DESC (for descending) parameter of the >KEY command:

  >KEY 42, 4, DESC

The file COMPANY would now list Receptionist, FRANCES JOHNSON as the first record in the file and President, CHARLES ANDERSON, as the last record in the file.




Using >VERIFY to Check Options


Sorting and Merging Multiple Files