Pricing changes are coming in January. Contact our Sales team to secure the current price for your desired license.
All documentation
  • API Reference for older versions
  • sortingMethod

    sortingMethod(uniqueName: String, compareFunction: Function)

    [starting from version: 2.6]

    Overrides the default ascending order of field members. For more details about overriding sorting order, refer to the Sorting tutorial.

    Parameters

    Parameter/TypeDescription
    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;
    });

    Live example

    See also

    Sorting
    setSort()
    getSort()
    sortValues()
    sortFieldsList()