descending( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Adds a sort stage that sorts the aggregation results by the specified fields in descending order.

The descending() method refines the aggregation to sort results in descending order of the specified fields. If you specify more than one field, descending() sorts the results in descending order by each field in the order they are listed.

You can sort the following types:

  • Number: Sorts numerically.
  • Date: Sorts by date and time.
  • String: Sorts lexicographically, so "abc" comes before "XYZ".
  • Reference: Compares by the ID of the referenced item as a String.

If a field contains a number as a String, that value is sorted alphabetically and not numerically. Items that do not have a value for the specified sort field are ranked lowest.

Method Declaration
Copy
Method Parameters
fieldsArray<string>

Fields to sort by.

Returns
Return Type:SortStage
Errors

This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?