Sorting documents You can sort page formatted documents retrieved from a document repository as well as page formatted documents from standard runtime jobs. The documents must be sorted to make sure they arrive in the right order before enveloping is applied. You can, for example, sort the documents using the zip code as the first sort criterion and the customer number as the second sort criterion. This will first group the documents per zip code, and then, within each zip code group, group the documents per customer number. Sort keys Sorting is applied using one or more sort keys, for example zip code and customer number as described in the example above. When you define a sort key, you define which key to use, the type of key (numeric or string), and the sort order (ascending or descending). How to define the sort keys depends on the source of the documents, i.e. the type of document repository from which the documents are retrieved. See the table below. Document repository Description FastObjects database If the documents are retrieved from a FastObjects database, you must use metadata as sort keys. You define the sort keys as variables ($<metadata>). See Sort keys for documents in FastObjects database. Relational database If the documents are retrieved from a relational database (Document Broker Plus), you must use metadata as sort keys. You define the sort keys as metadata names. See Sort keys for documents in relational database (Document Broker Plus). No document repository If the documents are defined by a document trigger, you can use any variable defined in the Project, for example the document trigger variable, as sort key. See Sort keys when no document repository is used.