sort() function

sort() orders rows in each intput table based on values in specified columns.

Output data

One output table is produced for each input table. Output tables have the same schema as their corresponding input tables.

Sorting with null values

When desc: false, null values are last in the sort order. When desc: true, null values are first in the sort order.

Function type signature
(<-tables: stream[A], ?columns: [string], ?desc: bool) => stream[A] where A: Record
For more information, see Function type signatures.



List of columns to sort by. Default is ["_value"].

Sort precedence is determined by list order (left to right).


Sort results in descending order. Default is false.


Input data. Default is piped-forward data (<-).


Sort values in ascending order

import "sampledata"
    |> sort()

View example input and output

Was this page helpful?

Thank you for your feedback!

Introducing InfluxDB 3.0

The new core of InfluxDB built with Rust and Apache Arrow. Available today in InfluxDB Cloud Dedicated.

Learn more

State of the InfluxDB Cloud Serverless documentation

The new documentation for InfluxDB Cloud Serverless is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.