Sorting by Multiple Keys
After you add a Sort component to the mapping, one sorting key called key is created by default.
Default Sort component
If you want to sort by multiple keys, adjust the Sort component as follows:
•Click the Add Key ( ) icon to add a new key (for example, key2 in the mapping below).
•Click the Delete Key ( ) icon to delete a key.
•Drop a connection onto the icon to add a key and also connect to it.
A mapping which illustrates sorting by multiple key is available at the following path: <Documents>\Altova\MapForce2022\MapForceExamples\SortByMultipleKeys.mfd.
In the mapping above, Person records are sorted by three sorting keys:
1.Shares (number of shares a person holds)
2.Last (last name)
3.First (first name)
Note that the position of the sorting key in the Sort component determines its sort priority. For example, in the mapping above, records are initially sorted by the number of shares. This is the sorting key with the highest priority. If the number of shares is the same, people are then sorted by their last name. Finally, when multiple people have the same number of shares and the same last name, the person's first name is taken into account.
The sort order of each key can be different. In the mapping above, the key Shares has a descending sort order (Z-A), while the other two keys have ascending sort order (A-Z).