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.
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.
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"]
.
desc
Sort results in descending order.
Default is false
.
tables
Input data.
Default is piped-forward data (<-
).
Examples
The following example uses data provided by the sampledata
package
to show how sort()
transforms data.
Sort values in ascending order
import "sampledata"
sampledata.int()
|> sort()
Sort values in descending order
import "sampledata"
sampledata.int()
|> sort(desc: true)
Sort by multiple columns
import "sampledata"
sampledata.int()
|> sort(columns: ["tag", "_value"])
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources:
InfluxDB Cloud customers can contact InfluxData Support.