Sorting, Outsorting, and Output

When you sort documents in an input, you change the order of the documents within the input before they are processed by the rules in your rule file. To sort, use the Sortmatch tag group in your control file to identify one or more input print streams to sort. The Sortmatch tag group begins with the <SORTMATCH> tag and ends with the </SORTMATCH> tag. Neither tag has parameters, and a control file can contain only one Sortmatch group.

For example, the following example shows coding in which Enrichment will sort documents within the print stream named Statements first by branch office (%%branch) and then by customer number (%%customer). The resulting output contains documents sorted in descending order by branch office. Within each branch office grouping, Enrichment sorts documents in ascending order by customer number.

<SORTMATCH>
<INPUTNAME> Statements
<SORT> %%branch D
<SORT> %%customer A
</SORTMATCH>

In this example, the Sortmatch tag group contains these tags:

  • <INPUTNAME> identifies an input to sort. You can specify as many <INPUTNAME> tags as there are Input groups in the control file. For more information, see the Enrichment Language Reference Guide.

    Note: Enrichment sorts documents before it processes the rule file, so you can only use variables extracted from the document or associated system variables as sort criteria. If you need to use other data, use the Presort tag group to sort outputs.

  • <SORT> identifies a field or system variable by which to sort documents within each input and specifies the resulting sort order. You can specify as many <SORT> tags as necessary. For more information, see the Enrichment Language Reference Guide.

Outsorting carries sorting a step further by separating documents from an input and assigning them to a specific output print stream based on field or system variable values. When outsorting to multiple output files, use an Output tag group to define each output file and then use <OUTPUT> commands in a rule file to direct specific documents to specific outputs.

The methods commonly used to sort and outsort output are described below.