WLJS LogoWLJS Notebook

PositionSmallest

PositionSmallest[list] gives the positions of the numerically smallest value in list.

PositionSmallest[list, n] gives the positions of the first n smallest values.

PositionSmallest[list, n, orderfun] gives the positions of the n smallest values as determined by orderfun.

Examples

Find position of the smallest element:

PositionSmallest[{5, 2, 8, 1, 9}]
(* {{4}} *)

Find positions of the 3 smallest:

PositionSmallest[{5, 2, 8, 1, 9}, 3]
(* {{4}, {2}, {1}} *)

Please visit the official Wolfram Language Reference for more details.

On this page