PositionLargest
✖
PositionLargest
gives the positions of the n largest values in list as determined by orderfun.
Details

- PositionLargest by default compares values by numerical magnitude, returning the list of positions of the largest value or n largest values.
- PositionLargest[list] gives a single list for the largest value.
- PositionLargest[list,n] gives a list of n sublists for the n largest values, or as many as are available if fewer than n.
- PositionLargest expects all objects to be comparable with one another, based on the ordering function.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Scope (6)Survey of the scope of standard use cases
Find positions of the two largest values in an association:

https://wolfram.com/xid/0c0p21z2jss76-diccrh

PositionLargest works with arbitrary numeric values:

https://wolfram.com/xid/0c0p21z2jss76-3dwb7v

PositionLargest can work with orderings of non-numeric data:

https://wolfram.com/xid/0c0p21z2jss76-j9ubu2

PositionLargest uses numeric ordering by default:

https://wolfram.com/xid/0c0p21z2jss76-ixmoen

Instead use canonical ordering:

https://wolfram.com/xid/0c0p21z2jss76-5skp60

PositionLargest works on lists of Quantity expressions:

https://wolfram.com/xid/0c0p21z2jss76-uidkau


https://wolfram.com/xid/0c0p21z2jss76-6zv4dw

PositionLargest works on lists of DateObject expressions:

https://wolfram.com/xid/0c0p21z2jss76-fdqisq


https://wolfram.com/xid/0c0p21z2jss76-ff2ija

Properties & Relations (4)Properties of the function, and connections to other functions
Find positions of the largest elements in a random list:

https://wolfram.com/xid/0c0p21z2jss76-r2351n

Compare to results using Position and Max:

https://wolfram.com/xid/0c0p21z2jss76-x9scg3

PositionLargest gives positions of all the largest elements:

https://wolfram.com/xid/0c0p21z2jss76-9m9r0q

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

https://wolfram.com/xid/0c0p21z2jss76-edayxf

One must specify the count of maximal elements to get all positions corresponding to the largest element using TakeLargest:

https://wolfram.com/xid/0c0p21z2jss76-y3ptag

Find positions of the largest elements in a random list:

https://wolfram.com/xid/0c0p21z2jss76-9cdsjz

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

https://wolfram.com/xid/0c0p21z2jss76-osokih

Find positions of the largest elements in a random list:

https://wolfram.com/xid/0c0p21z2jss76-tiqzrb

FindPeaks locates positions of all local maximal values:

https://wolfram.com/xid/0c0p21z2jss76-sfupkf

When you remove all peak positions that do not correspond to the global maximum value, you lose positions if there happen to be consecutive peaks:

https://wolfram.com/xid/0c0p21z2jss76-ra7zn7

Possible Issues (2)Common pitfalls and unexpected behavior
If fewer than the requested count of largest values are present, PositionLargest will give as many as are present:

https://wolfram.com/xid/0c0p21z2jss76-4cvnvp

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

https://wolfram.com/xid/0c0p21z2jss76-kng5d2


Wolfram Research (2022), PositionLargest, Wolfram Language function, https://reference.wolfram.com/language/ref/PositionLargest.html.
Text
Wolfram Research (2022), PositionLargest, Wolfram Language function, https://reference.wolfram.com/language/ref/PositionLargest.html.
Wolfram Research (2022), PositionLargest, Wolfram Language function, https://reference.wolfram.com/language/ref/PositionLargest.html.
CMS
Wolfram Language. 2022. "PositionLargest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PositionLargest.html.
Wolfram Language. 2022. "PositionLargest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PositionLargest.html.
APA
Wolfram Language. (2022). PositionLargest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PositionLargest.html
Wolfram Language. (2022). PositionLargest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PositionLargest.html
BibTeX
@misc{reference.wolfram_2025_positionlargest, author="Wolfram Research", title="{PositionLargest}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/PositionLargest.html}", note=[Accessed: 18-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_positionlargest, organization={Wolfram Research}, title={PositionLargest}, year={2022}, url={https://reference.wolfram.com/language/ref/PositionLargest.html}, note=[Accessed: 18-April-2025
]}