The rank function operates on a collection of numerical values. It sorts them in descending order (by default) and returns the rank (order) of the requested element in that order.


  • The numerical values should be available inside a collection.
  • Invoking the rank function on values other than numbers or decimals will result in a runtime error.

Return Type



<variable>=<collection>.rank(<number>, [<sort_order>]);


ParameterData typeDescription
<variable>NUMBERVariable which contains the rank of the requested element.
<numberCollection>COLLECTIONThe collection of numerical values.
<number>NUMBER / DECIMALThe numerical value for which the rank has to be determined.


TEXTThe rank is determined based on elements sorted in the descending order by default. This parameter is used to reverse the sorting order.

This parameter takes "asc" (case-insensitive) as a value.


 order=marks.rank(300);// the variable order is assigned the value 4

 order=marks.rank(80.5, "asc");// the variable order is assigned the value 2 as the elements are sorted in ascending order

 order=marks.rank(100);// A run-time error ('List contains invalid(TEXT) entries hence' can not be cast to 'valid list and perform desired operations') will be thrown as there is no such element

Related Examples

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com