Overrides the default ascending order of field members. For more details about overriding sorting order, refer to the Sorting tutorial.
Parameters
Parameter/Type
Description
uniqueName String
The unique name of the field to which the sorting is applied.
compareFunction Function
Defines the sort order. The input parameters are the same as for compareFunction of Array.sort() method.
Example
The following code sets custom sorting where members that begin with a specific letter (e.g., "F") are put first, while all other members remain in alphabetical order:
const letterToPutFirst = "F";
pivot.sortingMethod("Contact Last Name", function(a, b) { if (a.at(0) == letterToPutFirst && b.at(0) == letterToPutFirst) return a > b ? 1 : -1; if (a.at(0) == letterToPutFirst) return -1; if (b.at(0) == letterToPutFirst) return 1; return a > b ? 1 : -1; });