WLJS LogoWLJS Notebook

RankedMax

RankedMax[list,n] gives the nth largest element in list.

RankedMax[list,-n] gives the nth smallest element in list.

Examples

Get the 2nd largest element:

RankedMax[{3, 1, 4, 1, 5, 9, 2, 6}, 2]
(* 6 *)

Get the 3rd smallest element:

RankedMax[{3, 1, 4, 1, 5, 9, 2, 6}, -3]
(* 2 *)

Please visit the official Wolfram Language Reference for more details.

On this page