TakeSmallest

TakeSmallest[list,n]

gives the n numerically smallest elements in list, sorted in ascending order.

TakeSmallest[n]

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

Details and Options

Examples

open allclose all

Basic Examples  (5)

Take the two smallest numbers in a list:

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

Do the same using the operator form of TakeSmallest:

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

Take the two smallest values in an association:

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

Get the two smallest 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 least 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 four smallest 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

Min  TakeSmallestBy  TakeLargest  Sort  Take  MinimalBy  Ordering  RankedMin

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