Wolfram Computation Meets Knowledge

PositionLargest

The position of the largest elements in a list

ResourceFunction["PositionLargest"][list]

gives the position of the first element that has the largest value in list.

ResourceFunction["PositionLargest"][list,n]

gives the positions of the first n largest values.

Details and Options

All elements of list must be numeric.
UpTo[n] is supported.

Examples

Basic Examples

Find a position of the largest value in a list:

In[1]:=
ResourceFunction["PositionLargest"][{100, 200, 100, 200, 50}]
Out[1]=

Specify the number of positions to find:

In[2]:=
ResourceFunction["PositionLargest"][{100, 200, 100, 200, 50}, 1]
Out[2]=

Get a list of positions for the three largest values:

In[3]:=
ResourceFunction["PositionLargest"][{100, 200, 100, 200, 50}, 3]
Out[3]=

Scope

Use UpTo to find the position of the two largest moons orbiting each planet:

In[4]:=
moons = Values /@ ResourceData["Sample Data: Solar System Planets and Moons"][All, "Moons", QuantityMagnitude /* DeleteMissing, "Mass"]
Out[4]=
In[5]:=
ResourceFunction["PositionLargest"][#, UpTo[2]] & /@ moons
Out[5]=

Resource History