nthSmallest
Table of Contents
Overview
The nthSmallest function operates on a collection of numerical values. It sorts the values in ascending 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>.nthSmallest(<number>);
where,
Parameter | Data type | Description |
<variable> | NUMBER | Variable which contains the nth smallest value from the collection. |
<numberCollection> | COLLECTION | The collection of numerical values (includes NUMBER and DECIMAL). |
<number> | NUMBER / DECIMAL | The rank of the numerical value which needs to be retrieved from the collection. |
Examples
marks = {300,455,124,926,780}; result = marks.nthSmallest(2); info result; // Returns 300