Sentinel
Import: collection/lists
The collection/lists
import provides helpers for working with lists.
concat
concat(items, others[, ...additional])
Join multiple lists together, returning the resulting list. This helper must have at least two arguments supplied. Order is important, as the order of arguments is the order that lists will be appended.
Arguments
Name | Description |
---|---|
items | the first list to add to the resulting value |
others | the second list to add to the resulting value |
additional | any number of additional lists to add to the resulting value |
Examples
Concatenate two lists:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
Concatenate many lists:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
sort
sort(items, sort_function)
Sort will sort a list of elements according to the provided sort function, returning a new, sorted list.
Arguments
Name | Description |
---|---|
items | the list to sort |
sort_function | the function that is used to perform the sort |
Sort Function
The provided sort function accepts two arguments, which can be considered as the
current
and next
item. The function should return one of the following values:
Result | Description |
---|---|
-1 | current is less than next |
0 | current is equal to next |
+1 | current is greater than next |
The compare built-in method provides a way of performing comparisons against integers, floats or strings to return a supported value.
Examples
Sort a list of words:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
Sort a list of objects by a key:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
sum
sum(items)
Sum will add all elements within the provided list. The list must only contain integers or floats. The return value will always be a float.
Arguments
Name | Description |
---|---|
items | the list to sum |
Examples
Perform a sum on a list of numbers:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output