Skip to main content

Sort

Sorts all input records and returns them to the pipeline in sorted order. Sort requires at least one field and a sort order.

Single field ascending:

Simplest form:

<field_name>

Example:

"units_sold"

Multiple fields ascending:

Form:

[<field1_name>, <field2_name>, ...]

Example:

["product_category", "units_sold"]

Specify sort order:

{
<field1>: <sort order>,
<field2>: <sort order>,
...
}

<sort order> can have one of the following values:

ValueDescription
1Sort ascending
-1Sort descending

Example:

// sort by product_category ascending, then units_sold descending
{
"product_category": 1, // ascending
"units_sold": -1 // descending
}
Note, wonderment:

Right now it appears that sort requires an existing field. But should this allow expressions too?