nthLargest
Table of Contents
Overview
The nthLargest function operates on a collection of numerical values. It sorts the values in descending order and returns the value at the requested index in that order.
Note:
- The numerical values should be available inside a collection.
- The index argument cannot be greater than the size of the collection.
- The index argument starts from 1.
Return Type
- NUMBER / DECIMAL
Syntax
<variable> = <numberCollection>.nthLargest(<number>);
where,
Parameter | Data type | Description |
<variable> | NUMBER | Variable which contains the nth largest value from the collection. |
<numberCollection> | COLLECTION | The collection of numerical values (includes NUMBER and DECIMAL). |
<number> | NUMBER | The rank of the numerical value which needs to be retrieved from the collection. |
Examples
marks = Collection(300,455,124,926,780); result = marks.nthlargest(5); info result; // Returns 124