HELP SORT — VMS 5.0
Invokes the VAX Sort Utility (SORT) to reorder the records in a file
into a defined sequence and to create either a new file of the
reordered records or an address file by which the reordered records
can be accessed. For a complete functional description of the Sort
Utility, including more information about the SORT command, see the
VMS Sort/Merge Utility Manual.
Format:
SORT input-file-spec[,...] output-file-spec
Additional information available:
ParametersCommand QualifiersCommand QualifiersOutput File Qualifiers
Examples
Parameters
input-file-spec[,...] Specifies the name of the files whose records are to be sorted. You can sort up to 10 input files to create one output file. Multiple input file specifications must be separated by commas. If the file specifications do not include a file type, SORT assumes the default file type of DAT. No wildcard characters are allowed in the file specification. output-file-spec Specifies the name of the file into which the sorted records are to be written. If an address sort or index sort is selected, output file specification names the address file. If the file specification does not include a file type, SORT uses the file type of the first input file. No wildcard characters are allowed in the file specification.
Command Qualifiers
Additional information available:
/COLLATING_SEQUENCE/DUPLICATES/KEY/PROCESS
/SPECIFICATION/STABLE/STATISTICS/WORK_FILES
/COLLATING_SEQUENCE
/COLLATING_SEQUENCE=sequence Determines which collating sequence - ASCII, EBCDIC, or MULTINATIONAL - is used by SORT. SORT arranges characters in ASCII sequence by default. If the EBCDIC option is selected, input files are sorted as if the EBCDIC key characters were translated into ASCII key characters and then sorted as an ASCII key. Records do not change. Specifying the MULTINATIONAL option arranges the characters according to the MULTINATIONAL sequence, which is a collating sequence containing international characters.
/DUPLICATES
/DUPLICATES /NODUPLICATES By default, SORT retains records with equal keys. The /NODUPLICATES qualifier eliminates all but one of a record with equal keys. Because the record retained is unpredictable, you must specify which duplicate record to keep by invoking SORT at the program level and specifying an equal key routine. The /STABLE and the /NODUPLICATES qualifiers are mutually exclusive.
/KEY
/KEY=(field[,...])
Defines a sort key, including position, size, order, and data type.
If the key field starts in the first position, encompasses the
entire record, will be sorted in ascending order, and contains
character data, the /KEY qualifier need not be specified.
The key field is defined by keywords that must be separated with
commas and enclosed in parentheses.
Required Keywords
POSITION:n Specifies the position of the key within each
record, where the first character of each record
is position 1.
SIZE:n Specifies the length of the sort key in
characters, bytes, or digits, depending on the
key field data type. The total of all key field
sizes must be less than 32767 bytes. The valid
sizes, based on data types, are:
Data Type Values for n
character 1 through 32767 bytes
binary 1, 2, 4, 8, 16 bytes
decimal 1 through 31 digits
Optional Keywords
NUMBER:n Specifies the precedence of the sort key being
defined, where 1 represents the primary sort
key, 2 represents the secondary sort key, and so
on.
If this keyword is not specified in the first
/KEY qualifier, NUMBER:1 is assumed; if not
specified in any subsequent /KEY qualifiers, the
default value is the number assigned to the
previous key, plus 1.
The legal values are 1 through 255.
BINARY Indicates that binary data appears in the sort
key field. If no data type is specified, MERGE
assumes that the data type is CHARACTER.
CHARACTER Indicates that character data appears in the
sort key field. If no data type is specified,
MERGE assumes that the data type is CHARACTER.
DECIMAL Indicates that decimal data appears in the sort
key field. If no data type is specified, MERGE
assumes that the data type is CHARACTER.
D_FLOATING Indicates that d_floating data appears in the
sort key field. If no data type is specified,
MERGE assumes that the data type is CHARACTER.
F_FLOATING Indicates that f_floating data appears in the
sort key field. If no data type is specified,
MERGE assumes that the data type is CHARACTER.
G_FLOATING Indicates that g_floating data appears in the
sort key field. If no data type is specified,
MERGE assumes that the data type is CHARACTER.
H_FLOATING Indicates that h_floating data appears in the
sort key field. If no data type is specified,
MERGE assumes that the data type is CHARACTER.
PACKED_DECIMAL Indicates that packed decimal data appears in
the sort key field. If no data type is
specified, MERGE assumes that the data type is
CHARACTER.
ZONED Indicates that zoned data appears in the sort
key field. If no data type is specified, MERGE
assumes that the data type is CHARACTER.
SIGNED Indicates whether the key data type is signed
binary data.
UNSIGNED Indicates whether the key data type is unsigned
binary data.
LEADING_SIGN Indicates that the sign of a decimal data type
key appears at the beginning of the key. If the
key data type is specified as DECIMAL and if
neither LEADING_SIGN nor TRAILING_SIGN is
specified, the default is TRAILING_SIGN.
TRAILING_SIGN Indicates that the sign of a decimal data type
key appears at the end of the key. If the key
data type is specified as DECIMAL and if neither
LEADING_SIGN nor TRAILING_SIGN is specified, the
default is TRAILING_SIGN.
OVERPUNCHED_SIGN Indicates whether the sign of a decimal data
type key is superimposed on the decimal value.
If the key data type is specified as DECIMAL and
if neither of OVERPUNCHED_SIGN nor SEPARATE_SIGN
is specified, the default is OVERPUNCHED_SIGN.
SEPARATE_SIGN Indicates whether the sign of a decimal data
type key is separate from the decimal value .
If the key data type is specified as DECIMAL and
if neither of OVERPUNCHED_SIGN nor SEPARATE_SIGN
is specified, the default is OVERPUNCHED_SIGN.
ASCENDING Indicates that the key is to be sorted into
ascending order. The default is ASCENDING.
DESCENDING Indicates that the key is to be sorted into
descending order. The default is ASCENDING.
/PROCESS
/PROCESS=type
Defines the type of sort. Record sort is the default process. You
can specify one of the following sort types:
ADDRESS Requests that SORT produce an address file sorted by
record keys. The output file can be read as an index to
read the original file in the desired sequence.
INDEX Requests that SORT produce an address file containing the
key field of each data record and a pointer to its
location in the input file. The output file can be read
to access randomly the data in the original file in the
desired sequence.
RECORD Requests SORT to resequence the entire contents of the
input file and to create an output file containing the
reordered records.
TAG Requests SORT to sort only the record keys, and then to
randomly reaccess the input file to create an output file
containing the resequenced records.
/SPECIFICATION
/SPECIFICATION[=file-spec] Indicates that the command qualifiers, including key field definitions, are contained in a specification file. If no file specification is included, SORT reads the specification file from SYS$INPUT. The format and contents of the specification file are described in detail in the VMS Sort/Merge Utility Manual. No wildcard characters are allowed in the file specification.
/STABLE
/STABLE /NOSTABLE Specifies that SORT is to keep records with equal keys in their original order. If /STABLE is not specified, the order of records with equal keys is unpredictable.
/STATISTICS
/STATISTICS /NOSTATISTICS Specifies that a statistical summary is to be displayed after the SORT operation has completed. By default, no statistical summary is displayed.
/WORK_FILES
/WORK_FILES=n Specifies the number of temporary work files to be used during the sort process. You can specify 0 or any value from 2 through 10. A value of 0 indicates that no work files are necessary because the data will fit in physical memory.
Command Qualifiers
Additional information available:
/FORMAT
/FORMAT=(file-attribute[,...])
Specifies attributes of the input file to override the existing data
that SORT normally obtains through VAX-11 RMS. You can specify one
or both of the following keywords:
RECORD_SIZE:n Specifies, in bytes, the length of the longest
record, overriding the record size defined in the
file header or label. Specify a record size for an
input file when the input file is not on disk or if
the longest record size is known to be inaccurate.
The longest record length that can be specified is
32,767 bytes for sequential files, 16,383 bytes for
relative files, and 16,362 bytes for
indexed-sequential files.
FILE_SIZE:n Defines the size of the file in blocks. Specify a
file size for a file that is not on disk. If no
file size is specified for an input file, SORT uses
the default value of 1000 blocks.
The maximum file size that can be specified is
4,294,967,295 blocks.
If you specify both keywords, they must be separated by a comma and
enclosed in parentheses.
Output File Qualifiers
Additional information available:
/ALLOCATION/BUCKET_SIZE/CONTIGUOUS/FORMAT
/INDEXED_SEQUENTIAL/OVERLAY/RELATIVE/SEQUENTIAL
/ALLOCATION
/ALLOCATION=n Specifies the number of 512-byte blocks to be allocated for the output file. By default, SORT allocates blocks based on the number of records sorted. The /ALLOCATION qualifier accepts values of 1 through 4,294,967,295 blocks.
/BUCKET_SIZE
/BUCKET_SIZE=n Specifies the number of 512-byte blocks per bucket for the output file. The maximum size you can specify is 32 blocks. When you do not specify a bucket size and the output file has the same organization as the input file, the bucket size of the output file is the same as that of the input file. When you do not specify a bucket size and the output file has a different organization from that of the input file, the bucket size of the output file defaults to a value of 1.
/CONTIGUOUS
/CONTIGUOUS Controls whether the allocation of disk space for the output file is to be contiguous. If you specify /CONTIGUOUS, you must also specify /ALLOCATION to define the number of blocks to allocate for the output file. By default, SORT output is not contiguous.
/FORMAT
/FORMAT=(record-format[,...])
Defines the output file record format. You can specify one or more
of the following keyword options:
CONTROLLED[:n] Defines the output file record format and length,
where n is the length of the longest record in the
output file. If n is not specified, it defaults to
the length of the longest record in the input file.
FIXED[:n] Defines the output file record format and length,
where n is the length of the longest record in the
output file. If n is not specified, it defaults to
the length of the longest record in the input file.
VARIABLE[:n] Defines the output file record format and length,
where n is the length of the longest record in the
output file. If n is not specified, it defaults to
the length of the longest record in the input file.
BLOCK_SIZE:n Specifies, when the output file is directed to a
magnetic tape, the block size in bytes. By default,
SORT uses the block size of the input file if the
input file is a tape file. If the input file is not
a tape file, SORT uses, by default, the block size
specified when the output tape volume was mounted.
You can specify a block size in the range of 20
through 65,532. Note, however, that to ensure
compatible interchange with most non-DIGITAL
systems, the block size should be less than 2048
bytes.
If you do not specify /FORMAT to define the record format of the
output file, SORT assumes a default output format based on the sort
process selected, as follows:
o If the RECORD or TAG type of sort is selected, the output format
and record length default to the format and record length of the
first input file.
o If the ADDRESS or INDEX type of sort is selected, the output
record format defaults to FIXED.
/INDEXED_SEQUENTIAL
/INDEXED_SEQUENTIAL Specifies that the output file is in indexed sequential organization. If you specify /INDEXED_SEQUENTIAL, the output file must exist, its organization must be indexed, and it must be empty. Therefore, you must also specify /OVERLAY to overlay the existing file. By default, a record or tag sort creates an output file that is the same organization as the first input file. Specify /INDEXED_SEQUENTIAL to create an indexed sequential output file from a sequential or relative input file.
/OVERLAY
/OVERLAY Indicates that the existing file is to be overlaid with the sorted records of the input file. By default, SORT creates a new output file and does not overlay an existing file.
/RELATIVE
/RELATIVE Specifies that the output file is in relative file organization. By default, a record or tag sort results in an output file that has the same organization as the input file. Use /RELATIVE to create a relative output file from a sequential or indexed sequential input file.
/SEQUENTIAL
/SEQUENTIAL Specifies that the format of the output file is sequential organization. This is the default for an address or index sort process; for a record or tag sort process, the output file format defaults to the organization of the first input file. Specify /SEQUENTIAL to create an output file that is in a different format from the input file.
Examples
1. $ SORT/KEY=(POSITION:1,SIZE:70) -
_$ BOATS.LST BOATS.TMP
This SORT command sorts the records in the file BOATS.LST and
creates an output file named BOATS.TMP. All the records in the
input file are sorted in alphanumeric order based on the first 70
characters in each record.
2. $ SORT/KEY=(POSITION:47,SIZE:2)-
_$ /KEY=(POSITION:51,SIZE:7)-
_$ BOATS.LST BOATS.BEM
This SORT command specifies two key fields: the first key is in
columns 47 and 48 of each input record, and the second key is in
columns 51 through 57. The output file is named BOATS.BEM.