SORT_WORDS Function

Returns a string that consists of the words that are sorted alphabetically.

Category: String
Returned data type: String
Note: Special characters such as ",.!" are not treated as separation characters.

Syntax

SORT_WORDS(source<,ascending,remove_duplicates>)

Required Argument

source

specifies a string to sort; the string 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 words in the input string should be sorted in ascending order; this can be specified as a 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 words should be removed; this can be specified as a Boolean constant, field name, or expression. The value must evaluate to either TRUE or FALSE:

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

Details

In determining the order, words with initial capital letters precede lowercase letters. Also, words with a concatenated special character are treated as a different word. For example, first and first! are two different words.

Example

source_string =
     "It's a first! This is the first time I came in first place!"
ascending = true
remove_duplicates = true
result = sort_words(source_string, ascending, remove_duplicates)
// outputs "I It's This a came first first! in is place! the time"