Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

TakeSmallestBy

TakeSmallestBy[list,f,n]
gives the n elements ei in list for which f[ei] is smallest, sorted in ascending order.

TakeSmallestBy[f,n]
represents an operator form of TakeSmallestBy that can be applied to an expression.

Details and OptionsDetails and Options

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Take the two shortest strings in a list:

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

Do the same using the operator form of TakeSmallestBy:

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

Take the two longest strings in an association:

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

Give the four numbers closest to zero:

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

Give the 4 numbers closest to zero, or as many as are available if fewer:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2015
(10.1)
| Updated in 2015
(10.3)