sort() function

The sort() function orders the records within each table. One output table is produced for each input table. The output tables will have the same schema as their corresponding input tables.

*Function type: Transformation
**
Output data type:* Record

Sorting with null values

When sorting, null values will always be first. When desc: false, nulls are less than every other value. When desc: true, nulls are greater than every value.

  1. sort(columns: ["_value"], desc: false)

Parameters

columns

List of columns by which to sort. Sort precedence is determined by list order (left to right). Default is ["_value"].

*Data type: Array of strings*

desc

Sort results in descending order. Default is false.

*Data type: Boolean*

Examples

  1. from(bucket:"example-bucket")
  2. |> range(start:-12h)
  3. |> filter(fn: (r) =>
  4. r._measurement == "system" and
  5. r._field == "uptime"
  6. )
  7. |> sort(columns:["region", "host", "_value"])

Related articles