MinimalBy

MinimalBy[{e1,e2,},f]
returns a list of the ei for which the value of f[ei] is minimal.

MinimalBy[{e1,e2,},f,n]
returns a list of the ei corresponding to the n smallest f[ei].

MinimalBy[f]
represents an operator form of MinimalBy that can be applied to an expression.

DetailsDetails

  • Values of f[ei] are compared using the same canonical order as in Sort.
  • The minimal ei are returned in the order they appear in the input.
  • In the case of MinimalBy[list,f,n], the ei are sorted in the order of increasing f[ei], with those having the same value of f[ei] being taken in the order they appear in list.
  • MinimalBy[list,f, UpTo[n]] gives n elements, or as many as are available.
  • MinimalBy[f][expr] is equivalent to MinimalBy[expr,f].

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

Find the minimal element by last part:

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

All minimal elements are returned, in order of appearance:

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

Obtain the first three minimal elements:

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

Obtain the first 4 minimal elements, or as many as are available:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2014
(10.0)
| Updated in 2015
(10.3)
Translate this page: