A key function. Each element of the collection is passed to that function and then sorted based on the function's result. An underscore ( _ ) represents a placeholder, which is the value itself (dynamic reference).
A collection to be sorted.
Let's say we're given a response with the following vehicle information:
Example 1: Sort prices by numerical value
If we want to organize these prices by basic numerical value, we can use SORT with the dynamic references themselves serving as a sorting function.
# Sort prices using dynamic references
# Returns [9200, 16000, 17450]
Example 2: Sort strings using same arguments
We can also sort strings using SORT with dynamic references.
# Sort strings using dynamic references
# Returns ["Audi", "BMW", "Mercedes Benz"]
Example 3: Sort using a dynamic reference
We can also apply a function such as LEN to the dynamic reference. This sorts by length of string.
# Sort strings using the LEN function with dynamic references