arraySort - Sorts array according to arguments
The arraySort
function will sort an array acccording to some arguments, and return the sorted array.
Syntax
Like many functions in DataPrime, arraySort
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
Name | Type | Required | Description |
---|---|---|---|
array | array of type T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
desc | bool | false | when true , the array is sorted in reverse (descending) order. Must be a literal. Defaults to false |
nullsFirst | bool | false | when true , nulls will appear at the start of the output. Must be a literal. Defaults to false |
Example - Sorting names by alphabetical order
Consider the following document:
Sorting these names by alphabetical order is straight forward:
This results in the following document:
Theme
Light