In some of the components you need to define a sort key. Like a group key, this sort key can also be defined by selecting key fields using the Edit key dialog. There you can also choose what sort order should be used for each of the selected fields.
In the Edit key dialog, select the fields you want and drag and drop each of the selected key fields to the Key column of the Key parts pane on the right. (You can also use the Arrow buttons.)
Unlike in the case of a group key, in any sort key the order in which the fields are selected is of importance.
In every sort key, the field at the top has the highest sorting priority. Then the sorting priority descends down from top. The field at the bottom has the lowest sorting priority.
When you click the OK button, the selected fields will turn to a sequence of the same field names and an a
or a d
letter in parentheses (with the meaning: ascending
or
descending
, respectively) separated by semicolon.
It can look like this: FieldM(a);...FieldN(d)
.
This sequence can be seen in the corresponding attribute row. (The highest sorting priority has the first field in the sequence. The priority descends towards the end of the sequence.)
As you can see, in this kind of key, the sort order is expressed separately for each key field (either Ascending or Descending). Default sort order is Ascending. The default sort order can also be changed in the Order column of the Key parts pane.
Important | |
---|---|
ASCIIbetical vs. alphabetical order Remember that |
Example 46.1. Sorting
If your sort key is the following: Salary(d);LastName(a);FirstName(a)
. The records will be sorted according to the Salary
values in descending order, then the records will be sorted according to LastName
within the same Salary
value and they will be sorted according to FirstName
within the same LastName
and the same Salary
(both in ascending order) value.
Thus, any person with Salary
of 25000
will be processed after any other person with salary of 28000
. And, within the same Salary
, any Brown
will be processed before any Smith
. And again, within the same salary, any John Smith
will be processed before any Peter Smith
. The highest priority is Salary
, the lowest is FirstName
.
Sort key is used in the following cases:
Sort key in ExtSort
Sort key in FastSort
Sort key in SortWithinGroups
Dedup key in Dedup
Sort key in SequenceChecker