Skip to content

sort

Input Stack:
sortKey: String
expr: TimeSeriesExpr
Output Stack:
StyleExpr
 

Sort time series results for display in the legend and affect stacking order. The sort can be based on summary statistics computed over the time window or by the legend text. This operation primarily affects visual presentation - the order in which series appear in legends and the stacking order for area charts.

Parameters

  • expr: The time series expression to sort
  • sortKey: What to sort by - either a summary statistic name or legend for text

Sort Criteria

  • Summary statistics: max, min, avg, count, total, last, etc.
  • Legend text: Use legend to sort alphabetically by the series legend text
  • Default behavior: If no sort key is specified, defaults to sorting by legend text

The sort direction is ascending by default. Use :order to specify descending order.

Examples

Sorting by maximum value (highest values first when combined with desc order):

BeforeAfter
name,sps,:eq,
:sum,
(,nf.cluster,),:by
name,sps,:eq,
:sum,
(,nf.cluster,),:by,
max,:sort
  • :order - Control sort direction (ascending/descending)
  • :limit - Restrict results after sorting (e.g., top N)
  • :by - Group data that can then be sorted
  • Summary statistics - Available sort criteria

Since: 1.5