TakeLargest

TakeLargest[list,n]

gives the n numerically largest elements in list, sorted in descending order.

TakeLargest[n]

represents an operator form of TakeLargest that can be applied to an expression.

Details and Options

Examples

open allclose all

Basic Examples  (5)

Take the two largest numbers in a list:

In[1]:=
Click for copyable input
Out[1]=

Do the same using the operator form of TakeLargest:

In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

Take the two largest values in an association:

In[4]:=
Click for copyable input
Out[4]=

Get the two largest quantities in a list of Quantity objects:

In[1]:=
Click for copyable input
Out[1]=

Quantities can be present in multiple units:

In[2]:=
Click for copyable input
Out[2]=

Get the two most recent dates in a list of DateObject constructs:

In[1]:=
Click for copyable input
Out[1]=

By default, Missing[] and several other symbolic expressions are excluded from the results:

In[1]:=
Click for copyable input
Out[1]=

Take the 4 largest numbers, or as many as are available if fewer:

In[1]:=
Click for copyable input
Out[1]=

Options  (1)

Possible Issues  (2)

Neat Examples  (1)

See Also

Max  TakeLargestBy  TakeSmallest  Sort  Reverse  Take  MaximalBy  Ordering  RankedMax

Introduced in 2015
(10.1)
| Updated in 2015
(10.3)