SORT Function

Returns a string with its characters sorted alphabetically.

Category: String
Returned data type: String

Syntax

SORT(source <, ascending, remove_duplicates>)

Required Argument

source

specifies a string to sort; this can be specified as string constant, field name, or expression.

Note If source is NULL, the function returns a NULL value.

Optional Arguments

ascending

specifies whether the text should be sorted in ascending order; this can be specified as Boolean constant, field name, or expression. The value must evaluate to either TRUE or FALSE:

TRUE the input string is sorted in ascending order.
FALSE the input string is sorted in descending order.
Default TRUE

remove_duplicates

specifies whether duplicate characters should be removed; this can be specified as Boolean constant, field name, or expression. The value must evaluate to either TRUE or FALSE:

TRUE duplicate characters are removed.
FALSE duplicate characters are not removed.
Default FALSE

Details

In determining the order, special characters precede initial capital letters, which precede lowercase letters.

Example

source_string = "A short Sentence."
ascending = true
remove_duplicates = true
result = sort(source_string, ascending, remove_duplicates)
// outputs ".AScehnorst"