HomeGuides
Log In
Guides

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:

  1. Double-click the component.
  2. In the Edit component ExtSort window, click the Sort key row in the component editor. A button appears in this row.
  1. Click the button to open the Select Fields dialog window.
  2. 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 with LastName and FirstName items in this order.
  1. Click the cell in the Order column on the right of the salary item and select Descending instead of Ascending.
    In this way you have selected the fields according to which the incoming records will be sorted. The records will be sorted according to the salary field values in descending order. Records with the same salary will be sorted according to the lname in ascending order. Records with the same salary and lname will be sorted according to the 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.
  2. 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.