Returns a ->subSequence of the first integer entities in the collection <Sequence>. Another operator, such as ->sortedBy or ->sortedByDesc, must be used to transform a <Collection> into a <Sequence> before ->first can be used. <Sequence> must be expressed as a unique alias. If integer is larger than the number of entities in the collection, all the entities in the collection are returned. See Advanced Collection Syntax for more examples of usage.
This sample Rulesheet uses ->first(2) to select the first two elements of the sequence created by applying ->sortedBy to collection2. Once identified, the first 2 entities will be returned as the sequence collection3.
SAMPLE RULETEST
A sample Ruletest provides a collection of five elements, each with a decimal1 value. Input and Output panels are shown below.
Note: The selected entities and their values are highlighted to improve readability.
RULESHEET EXAMPLE: USING DESCENDING SORT
Sometimes it is easier to understand this type of action when you sort the data in descending order; when thinking of the "the top three sales figures", the first three largest values are what is intended. In this example, the action uses ->sortByDesc to order the collection largest-to-smallest and then moves the top 2 entities to the result sequence:
SAMPLE RULETEST: USING DESCENDING SORT
The sample Ruletest shows the two entities with the highest values are copied to the results sequence:
Note: The selected entities and their values are highlighted to improve readability.