sort

Organizes records in a Salesforce Spiff data filter by a date, string value, or number value and returns a list of sorted records.

Required Editions

Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience
Available in: Enterprise, Unlimited, and Developer Editions
Available for an additional cost in: Professional Edition with Web Services API Enabled

Syntax

sort(scope, sort_criteria, direction)

Arguments

Argument Required? Description
scope Required A data filter or list to sort.
sort_criteria Required An expression that specifies the field or calculation to sort the data filter or list by.
direction Optional

An integer that specifies how the data is sorted.

  • To sort the data in ascending order, use 1. This value is the default.
  • To sort the data is descending order, use -1.

Example

Sort records in the ClosedInPeriod data filter by ARR__c field value in ascending order.

=sort(ClosedInPeriod, ARR__c, 1)

Sort records in the ClosedInPeriod data filter by CloseDate in descending order.

=sort(ClosedInPeriod, CloseDate, -1)
Important
Important The sort() function doesn't work with lists of primitive values, such as a list of raw numbers.