Sort

The Sort processor is used to sort datasource records using specified criteria in the ascending or descending order. It includes a Group On option to group the records depending on their values or specified ranges. In limited levels of sorting and grouping can be done on a dataset. The Group Range used for delimiting groups can be specified for a field of type number, date or string.

An Expression Builder is provided to assist in the extraction of ranges of records. Using this, the top n or bottom m records present in the datasource can be retained. These values need not be constants, they can be variables and also include precentages.

Add Sort

The simple example below sorts the records for the DataSource processor.

To do so, select the button on the menu bar and click on the location in the designer diagram. Use the Flow connector to connect the Sort and DataSource processors together.

The Sort processor is present but the sorting method is not defined yet.

Edit Sort

After the Sort and DataSource processors are connected together, you may need to edit the properties of the Sort processor.

There are two ways to access the properties of the Sort processor.

  • Double-click on the Sort processor
  • Right-click on the Sort processor and select the “Properties” option from the pop-up menu

Either one method will launch the Sort Wizard.

On the left of the page, there are a column of buttons, namely “Add”, “Edit”, “Delete”, “Move Up” and “Move Down”. These buttons allows you to add/edit/delete fields for sorting and the sorting order.

To add a field to sort, click on the “Add” button on the left. A “Sort” dialog box will appear.

Field Description
Name Selects the field to sort from drop-drop list.
Sort Order Selects the sorting order from drop-down list.
Default value is “None”.
The “Simple Ascending” and “Simple Descending” sort compares unicode character values literally and does not ignore spaces.
Group On Selects how the records are grouped from drop-down list.
Default value is “None”.
Derived Field Defines a name for the derived field from the sorted list.
A new field will be created in the output schema for this field.

The common options available for the “Group On” field varies according to the type of field selected in the “Name” field.

Type vs Option Description Numerical Data String Date Data
Each Value Consecutive records (After sorting) with same selected field value are grouped together. Y Y
Substring A “[Start,End]” textbox will appear to specify the starting and ending character of the string.
For example, [0,3] is specified, then the grouping will be based on 3 characters starting from the first character of the string (indexes are zero-based).
Y Y Y
Range A “Range” textbox will appear to specify one of the two types of syntax for the range.
First type of syntax is [condition]:label. For example, <x:A, where x is threshold value based on which grouping is done and A is the label name assigned for the group.
The other type of syntax is step(value,value,value). For example, step(x,y,z), where x is start value, y is increment and z is stop value.
A number of ranges can be specified for both types.
Y Y
All All records are grouped together irrespective of selected field value. Y Y Y
Count Records are grouped with a fixed number of records in each group. Y Y Y

The list below are the options for “Date Data” only. The “Hour”, “Minute” and “Second” options are available only if the date field contains time or if time field is selected.

  • Year
  • Quarter
  • Month
  • Month (Name)
  • Month (Short Name)
  • Week of Year
  • Week of Month
  • Day of Year
  • Day of Month
  • Day of Week
  • Day of Week (Name)
  • Day of Week (Short Name)
  • Hour
  • Minute
  • Second

For these options, an additional field “Group Interval” will appear to specify the group interval.

For example, the “Day of Week” option is selected and 2 is entered to the “Group Interval” field. The grouping output is Monday-Tuesday, Wednesday-Thursday, Friday-Saturday and Sunday. Records corresponding to the fields having Monday and Tuesday are grouped together, etc. If the day of week grouping has to be done for a particular interval of year and months, then the years are grouped first followed by month grouping, then finally the week grouping is done.

The same logic applies to other options.

Select as desired and click on the “OK” button to exit the “Sort” dialog box.

The sort details will appear in the Sort Wizard.

Once all desired sort details are added, click on the “Next” button.

This page allows you to create an expression builder and display the command string.

Field Description
Top If selected, the top n number of records are to be retained.
Bottom If selected, the bottom n number of records are to be retained.
Amount Defines the n number.
Percent If selected, the “Amount” value represents a percentage of the total number of records flowing through.
Level Indicates the level at which the extraction algorithm applies.
A value of 0 indicates all records.
A value of 1 indicates the top n records of each group level 1 will be retained.
The value can vary between 0 and the number of grouping levles identified on the previous page.

Set up the expression builder as desired and click on the “Set Value” button. The command string will be displayed in the “Extract” field.

Click on the “Finish” button to save and exit the Sort Wizard. Click on the “Previous” button to go back to the previous page. To abort, click on the “Cancel” button.

Delete Sort

To remove the Sort processor, simply select the Sort processor and click on the “delete” key on your keyboard. Alternatively, right-click on the Sort processor to display the pop-up menu and select “Delete Graphic” option.

Pop-up Menu

To access the pop-up menu of the Sort processor, right-click on the processor.

There are three functions in the pop-up menu.

Function Description
Properties Launches the Sort Wizard that allows you to edit the properties of the Sort processor.
View Output Switches to the “Data” tab, which displays the records of the datasource after the sort operation.
Delete Graphic Deletes the Sort processor.