SORT Utility

SORT is a procedure in the operating system that sorts a file or a set of records into a single file of ordered records. SORT can also merge a set of presorted files into a single ordered file. SORT can be activated through ALGOL, COBOL74, COBOL85, FORTRAN77, C, Pascal, Pascal83, the sort procedural interface, the Interactive Sort (ISORT) utility, or the SORT compiler. Refer to the Interactive Sort (ISORT) Operations Guide for more information on the Interactive Sort utility.

You cannot use the SORT utility for EDRC compressed tape files.

The SORT compiler supports the MultiLingual System (MLS), allowing error and warning messages as well as header and trailer messages to be reworded or translated according to need. For more information, refer to the Message Translation Utility (MSGTRANS) Operations Guide.

SORT accepts a number of parameters that specify where to get the input, the comparison technique to be used, where to place the sorted records, what system resources to use for the sort operations, and so forth.

All languages except the SORT compiler require you to provide a certain set of parameters—such as input, output, and comparison. The SORT compiler builds the calls on the SORT intrinsic, based on the information you enter in the SORT language. Refer to the SORT Language Programming Reference Manual for a detailed description of the SORT compiler. This section does not discuss the SORT compiler.

SORT can be operated in four different modes:

  • Disk-only mode

  • Tape-only mode

  • Integrated tape and disk (ITD) mode

  • Memory mode

Sort operations can be restarted.

Sorting is performed in two phases:

  • The sorting or stringing phase

  • The merging phase

SORT begins by reading records from the input file or procedure and sorting them into groups, called strings, on the sort work files.

After the last input record is read, the merging phase begins. The strings of sorted records are merged into larger strings until the result is one string containing the ordered records from the input file. The ordered records are then written to the output file or procedure, and the SORT utility terminates.