Sorting the Records
Let's see how to sort records with the ExtSort component.
We are going to use the graph designed in the Creating a Transformation Graph section.
Adding ExtSort
Setting Up the ExtSort Component
Follow these steps to set up the ExtSort component:
- Double-click the component.
- In the Edit component ExtSort window, click the Sort key row in the component editor. A button appears in this row.
- Click the button to open the Select Fields dialog window.
- To select the key that will be used to sort incoming records, drag the
Salary
item from the Fields pane and drop it to the Sort key pane. Do the same withLastName
andFirstName
items in this order.
- Click the cell in the Order column on the right of the
salary
item and selectDescending
instead ofAscending
.
In this way you have selected the fields according to which the incoming records will be sorted. The records will be sorted according to thesalary
field values in descending order. Records with the samesalary
will be sorted according to thelname
in ascending order. Records with the samesalary
andlname
will be sorted according to thefname
in ascending order.
Thus, any person withsalary
of25000
would be sent out after any other person with salary of28000
. And, within the samesalary
, anyBrown
would be sent out through the output port before anySmith
. And again, within the same salary, anyJohn Smith
would be sent out before anyPeter Smith
.
In other words, the fields located higher in the Key parts pane have higher sorting priority. - After clicking OK, a sequence of field names separated by semicolon will appear in the component editor:
Run the graph and see the results.
You can see that all salaries are sorted in descending order. Note that within the same salary of 30,000 both Browns
lies above George Smith
and that Albert Brown
lies higher than Peter Brown
.
Updated 11 months ago