sort

Sort the data in a data extract.

This guide explains how to configure the sort instruction. To learn about another instruction, go back to the Available custom script instructions overview.

Introduction

Use the sort instruction to sort data in the data extract. You can enter multiple columns to sort. The order in which you enter the columns is the order in which the columns are sorted. See the example below.

Creating a custom script enrichment using the sort instruction

To create and configure a custom script using the sort instruction, follow these steps:

  1. Create a custom script enrichment.

  2. In the Instructions step, select the sort instruction.

  3. To configure the custom script instruction, fill in the following fields. Required fields are marked with an asterisk (*).

Key

Enter the name of the column to use to sort your data. Click to add another column to sort by, after sorting by the previous column(s).

Reverse

Select this field to sort the data in reverse. If left unselected, the data is ordered in ascending order.

Subtable

Enter the name for a subtable that you want to use within this custom script.

A subtable is a temporary table that only exists for this custom script. You can apply additional instructions within the same custom script to the subtable. However, the subtable cannot be used in any other custom scripts.

If a subtable does not exist for the current custom script, the enrichment is applied to the data extract, and the enriched data is output into the subtable. If the subtable already exists for the custom script, the subtable is used as the input for the enrichment and optionally as the output.

Example

Enrichment configuration

Key

Campaign

Ad Group

Data table before enrichment

Campaign

Ad Group

Clicks

Brand

media

7

Brand

ecommerce

3

Dashboard

ecommerce

18

Brand

ecommerce

4

Dashboard

media|social

5

Dashboard

media

11

Data table after enrichment

Campaign

Ad Group

Clicks

Brand

ecommerce

3

Brand

ecommerce

4

Brand

media

7

Dashboard

ecommerce

18

Dashboard

media

11

Dashboard

media|social

5