WOLFRAM

gives the positions of the numerically smallest value in list.

gives the positions of the first n smallest values.

PositionSmallest[list,n,orderfun]

gives the positions of the n smallest values in list as determined by orderfun.

Details

  • PositionSmallest by default compares values by numerical magnitude, returning the list of positions of the smallest value or n smallest values.
  • PositionSmallest[list] gives a single list for the smallest value.
  • PositionSmallest[list,n] gives a list of n sublists for the n smallest values, or as many as are available if fewer than n.
  • PositionSmallest expects all objects to be comparable with one another, based on the ordering function.

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Find positions of the smallest value in a list:

Out[1]=1

Get lists of positions for the three smallest values:

Out[1]=1

Scope  (6)Survey of the scope of standard use cases

Find positions of the two smallest values in an association:

Out[1]=1

PositionSmallest works with arbitrary numeric values:

Out[1]=1

PositionSmallest can work with orderings of non-numeric data:

Out[1]=1

PositionSmallest uses numeric ordering by default:

Out[1]=1

Instead use canonical ordering:

Out[2]=2

PositionSmallest works on lists of Quantity expressions:

Out[1]=1
Out[2]=2

PositionSmallest works on lists of DateObject expressions:

Out[1]=1
Out[2]=2

Properties & Relations  (4)Properties of the function, and connections to other functions

Find positions of the smallest elements in a random list:

Out[33]=33

Compare to results using Position and Min:

Out[3]=3

PositionSmallest gives positions of all the smallest elements:

Out[1]=1

TakeSmallest will only give as many element positions as are requested:

Out[2]=2

One must specify the count of minimal elements to get all positions corresponding to the smallest element using TakeSmallest:

Out[3]=3

Find positions of the smallest elements in a random list:

Out[1]=1

One can use Ordering once the number of smallest elements is known:

Out[2]=2

Find positions of the smallest elements in a random list:

Out[1]=1

FindPeaks locates positions of all local minimal values:

Out[2]=2

Remove all peak positions that do not correspond to the global minimum value:

Out[3]=3

Possible Issues  (2)Common pitfalls and unexpected behavior

If fewer than the requested count of smallest values are present, PositionSmallest will give as many as are present:

Out[1]=1

If the elements are not comparable, PositionSmallest will not evaluate:

Out[1]=1
Wolfram Research (2022), PositionSmallest, Wolfram Language function, https://reference.wolfram.com/language/ref/PositionSmallest.html.
Wolfram Research (2022), PositionSmallest, Wolfram Language function, https://reference.wolfram.com/language/ref/PositionSmallest.html.

Text

Wolfram Research (2022), PositionSmallest, Wolfram Language function, https://reference.wolfram.com/language/ref/PositionSmallest.html.

Wolfram Research (2022), PositionSmallest, Wolfram Language function, https://reference.wolfram.com/language/ref/PositionSmallest.html.

CMS

Wolfram Language. 2022. "PositionSmallest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PositionSmallest.html.

Wolfram Language. 2022. "PositionSmallest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PositionSmallest.html.

APA

Wolfram Language. (2022). PositionSmallest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PositionSmallest.html

Wolfram Language. (2022). PositionSmallest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PositionSmallest.html

BibTeX

@misc{reference.wolfram_2025_positionsmallest, author="Wolfram Research", title="{PositionSmallest}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/PositionSmallest.html}", note=[Accessed: 22-April-2025 ]}

@misc{reference.wolfram_2025_positionsmallest, author="Wolfram Research", title="{PositionSmallest}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/PositionSmallest.html}", note=[Accessed: 22-April-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_positionsmallest, organization={Wolfram Research}, title={PositionSmallest}, year={2022}, url={https://reference.wolfram.com/language/ref/PositionSmallest.html}, note=[Accessed: 22-April-2025 ]}

@online{reference.wolfram_2025_positionsmallest, organization={Wolfram Research}, title={PositionSmallest}, year={2022}, url={https://reference.wolfram.com/language/ref/PositionSmallest.html}, note=[Accessed: 22-April-2025 ]}