Alteryx Sort Tool

The Alteryx sort tool helps you sort the source data based on one or more columns in ascending and descending order. To demonstrate the sort tool, we used the below Customer_Country text file.

Choose the Text File

First, drop the Input Data Tool, and within the Configuration tab, click on the down arrow button to connect to a Customer_Country Text File. Once you select the text file, the following Resolve File Type window will open. We have chosen the Read it as a delimited text file option and set the Comma. Please refer to the Load CSV file article.

Alteryx Sort Ascending and Descending

Within the Favorites tab, drag the Sort tool to the canvas and add the Input Data tool output to the Sort tool. We can select the field or column names within the Sort configuration tab and the sorting order (Ascending or Descending). If you click on the down arrow, you can see the list of available columns to perform sorting.

Sort Tool - Ascending and Descending 4

We selected the Education Column and the Sort order as Ascending. It means the Alteryx sort tool has to sort the Customers by Education in ascending order. Run and see the sorted output.

Sort Tool - Ascending and Descending 6

This time, we added an occupation column in ascending order. As you can see, Customers are sorted by education and then occupation.

Multiple columns in Ascending 7

We can also use the combination of ascending and descending order. It sorts the customers by education in ascending and country names in descending order.

Multiple Columns with Ascending and Descending options

When we try to sort the Sales column in ascending order, it gives a strange result. It is because the sales column is of string type.

Sort Tool - Ascending and Descending 9

If you want to sort the string column with numeric values, try using the Alteryx dictionary order option. It might give the correct result but is not recommended.

Please use the drop-down list beside the User Dictionary Order label to see a list of languages supported by Alteryx dictionary order.

As I said earlier, we have to change the column type to numeric to sort the numeric values. We added the Select tool in between the Input and Sort tools and changed the Sales column to double.

Use the Select tool to change the Numeric data type

Now you can see the Sales columns sorted in ascending order.

Sort Tool - Ascending and Descending 13

Here, the sort tool sorts the customers by country in ascending and sales by descending.

Sort Tool - Ascending and Descending 14