Version

    72. Sorting the Records

    In this chapter we will learn how to sort records with the ExtSort component.

    This chapter builds on the graph from Creating a Transformation Graph.

    Adding ExtSort

    sorting 0110
    Figure 519. Adding ExtSort Component

    Setting Up the ExtSort Component

    Double-click the ExtSort component.

    Click the Sort key row in the component editor. A button appears in this row.

    extsort 010
    Figure 520. Editing ExtSort Component

    Use the button to open Sort Key dialog:

    extsort 020
    Figure 521. Selecting a Sort Key

    Select the key that will be used for sorting the incoming records. Drag the Salary item from the Fields pane and drop it to the Sort key pane. Do the same with LastName and FirstName items in this order.

    extsort 028
    Figure 522. Sort Key Selection

    Click the cell in the Order column right from the salary item and select Descending instead of Ascending.

    This way you have selected the fields according to which the incoming records should be sorted. The records will be sorted according to the salary field values in descending order. Records with same salary will be sorted according to lname in ascending order. Records the same salary and lname will be sorted according to fname in ascending order.

    Thus, any person with salary of 25000 would be sent out after any other person with salary of 28000. And, within the same salary, any Brown would be sent out through the output port before any Smith. And again, within the same salary, any John Smith would be sent out before any Peter Smith.

    In other words, the fields located higher in the Key parts pane have higher sorting priority.

    extsort 030
    Figure 523. Sort Key Selection

    After clicking OK, a sequence of field names separated by semicolon will appear in the component editor:

    extsort 040
    Figure 524. Sort Key Appearance

    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 30000 both Browns lies above George Smith and that Albert Brown lies higher than Peter Brown.