TakeSmallest[data,n]
gives the n smallest elements of data, sorted in ascending order.
TakeSmallest[dataprop,n]
gives the property prop for the n smallest elements in data.
TakeSmallest[data,n,p]
uses the order function p for sorting.
TakeSmallest[n]
represents an operator form of TakeSmallest that can be applied to an expression.
TakeSmallest
TakeSmallest[data,n]
gives the n smallest elements of data, sorted in ascending order.
TakeSmallest[dataprop,n]
gives the property prop for the n smallest elements in data.
TakeSmallest[data,n,p]
uses the order function p for sorting.
TakeSmallest[n]
represents an operator form of TakeSmallest that can be applied to an expression.
Details and Options
- TakeSmallest gives the smallest elements in the first level of the input data. »
- By default, TakeSmallest uses NumericalOrder to sort numeric expressions, Quantity objects and DateObject expressions. For other types of objects, TakeSmallest sorts by canonical Order.
- The data can have the following forms:
-
{e1,e2,…} list of values, including numbers, quantities, dates, ... » » » Association[…] association of values » QuantityArray[…] quantity array or other structured array » Tabular[…] type-consistent tabular data » TabularColumn[…] type-consistent column data » Dataset[…] general hierarchical data » - TakeSmallest[assoc,n] gives an association of length n by taking the n smallest values in assoc, preserving their keys.
- In TakeSmallest[dataprop,n], possible forms for prop include:
-
"Element" gives each element itself » "Index" gives the index for each element » {prop1,prop2,…} a list of multiple forms » All gives an association with element and index » - TakeSmallest[data,UpTo[n]] takes n smallest elements, or as many as are available. »
- TakeSmallest[n][data] is equivalent to TakeSmallest[data,n].
- TakeSmallest has option ExcludedForms. With the default setting ExcludedForms->Automatic, TakeSmallest drops elements that are None, Null or Indeterminate or have head Missing. »
- The setting ExcludedForms->{patt1,patt2,…} specifies that expressions matching any of the patti should be excluded from results generated by TakeSmallest. »
Examples
open all close allBasic Examples (4)
Take the two smallest numbers in a list:
TakeSmallest[{1, 3, 5, 4}, 2]Do the same using the operator form of TakeSmallest:
{1, 3, 5, 4}//TakeSmallest[2]TakeSmallest[2] @ {1, 3, 5, 4, 2}Get the three smallest quantities in a list of Quantity objects:
TakeSmallest[{Quantity[1, "Kilograms"], Quantity[2, "Kilograms"], Quantity[3, "Kilograms"]}, 3]Quantities can be present in multiple units:
TakeSmallest[{Quantity[1, "Grams"], Quantity[2, "Kilograms"], Quantity[3, "Milligrams"]}, 3]Get the two least recent dates in a list of DateObject constructs:
TakeSmallest[{Yesterday, Today, Tomorrow}, 2]Take the three smallest values in an association:
TakeSmallest[<|a -> 1, b -> 2, c -> 3, d -> 4, e -> 5|>, 3]Scope (9)
Take the four smallest numbers or as many as are available if fewer:
TakeSmallest[{1, 7, 4}, UpTo[4]]Quantities can be given as QuantityArray:
TakeSmallest[QuantityArray[{1, 2, 3}, "kg"], 2]Normal[%]By default, Missing[] and several other symbolic expressions are excluded from the results:
TakeSmallest[{1, 3, 5, None, Indeterminate, Missing[]}, 2]Get the two smallest elements in a list:
list = {E^π, 7 π, π^E, 23};TakeSmallest[list -> "Element", 2]Get the positions of the two smallest elements in a list:
TakeSmallest[list -> "Index", 2]Get the two smallest elements in a list along with their positions:
TakeSmallest[list -> {"Element", "Index"}, 2]Get the two smallest elements in a list with their positions given first:
TakeSmallest[list -> {"Index", "Element"}, 2]Get associations containing the element and position of the two smallest elements in a list:
TakeSmallest[list -> All, 2]Find the three smallest elements in a TabularColumn:
TabularColumn[{16.1, 29.2, 33.8, 14.7, 30.1, 27.5, 36., 35.1}]TakeSmallest[%, 3]Normal[%]Get the four rows with the smallest element in the first column in a Tabular object:
data = {{8, 13, 18, 8, 14, 13, 18, 27}, {16.1, 29.2, 23.8, 14.7, 30.1, 27.5, 35.1, 36.2}};
tab = ToTabular[data, "Columns", {"size", "length"}]TakeSmallest[tab, 4]Normal[%]Take a list of numeric expressions or infinities:
list = {E^π, 7 π, π^E, 23, -Infinity};By default, TakeSmallest sorts the elements using NumericalOrder:
TakeSmallest[list, 3]Sort[list, NumericalOrder]Use canonical Order instead:
TakeSmallest[list, 3, Order]Sort[list]Take a list of lists of integers:
list = {{3, 7}, {2, 7, 2}, {0, 1, 3, 4}};They are not numeric elements, so they are sorted by default following canonical order:
TakeSmallest[list, 2]Sort[list]Use instead lexicographic order, which will sort the list by their respective first elements:
TakeSmallest[list, 2, LexicographicOrder]Sort[list, LexicographicOrder]Take a list of complex numbers:
list = RandomComplex[{-10 - 10I, 10 + 10I}, 5]Following NumericalOrder, TakeSmallest selects numbers with decreasing real part:
TakeSmallest[list, 3]Sort[list, NumericalOrder]Options (2)
ExcludedForms (2)
By default, Missing[] and several other symbolic expressions are excluded from the results:
TakeSmallest[{1, 3, 5, None, Indeterminate, Missing[]}, UpTo[4]]Specify which elements should be excluded:
TakeSmallest[{1, 3, 5, None, Indeterminate, Missing[]}, UpTo[4], ExcludedForms -> {None, Indeterminate}]By default, TakeSmallest takes all elements into account when finding the smallest ones:
TakeSmallest[{6, -3, 4, x, 2, y, z}, UpTo[6]]TakeSmallest[{6, -3, 4, x, 2, y, z}, UpTo[6], ExcludedForms -> {x, y}]Exclude elements matching a given pattern:
TakeSmallest[{6, -3, 4, x, 2, y, z}, UpTo[6], ExcludedForms -> {_Symbol}]Applications (6)
Get the three planets with the smallest radii:
TakeSmallest[EntityValue["Planet", "Radius", "EntityAssociation"], 3]Get the release dates of the five oldest James Bond movies:
TakeSmallest[EntityValue[EntityClass["Movie", "JamesBondFranchise"], EntityProperty["Movie", "ReleaseDate"], "EntityAssociation"], 5]Find the South American countries with the lowest life expectancy for their inhabitants:
data = EntityValue[EntityClass["Country", "SouthAmerica"], EntityProperty["Country", "LifeExpectancy"], "EntityAssociation"];TakeSmallest[data, 2]Find the codons (groups of three consecutive nucleotides) with the lowest relative frequencies in the list of nucleotides of a gene:
dnasequence = GenomeData["SCNN1A", "FullSequence"];
codons = StringPartition[dnasequence, 3];
frequencies = N[Counts[codons] / Length[codons]];TakeSmallest[frequencies, 3]Find the noble gases with the lowest boiling point and density:
gases = EntityValue[EntityClass["Element", "NobleGas"], {"BoilingPoint", "Density"}, "Dataset"];gases[TakeSmallest[2], "BoilingPoint"]gases[TakeSmallest[2], "Density"]Find the five least dense chemical elements:
EntityValue[EntityClass["Element", All], "Density", "EntityAssociation"]//TakeSmallest[5]Properties & Relations (6)
TakeSmallest[list,n,p] is effectively equivalent to Take[Sort[list,p],n]:
list = Sqrt /@ RandomInteger[1000, 6]Take[Sort[list, NumericalOrder], 2]TakeSmallest[list, 2]TakeSmallest uses NumericalOrder as default ordering function p:
TakeSmallest[list, 2, NumericalOrder]Using canonical order can give different results:
TakeSmallest[list, 2, Order]With numerical inputs, the result of TakeSmallest is determined by numerical comparisons:
list = {1, 7, 4, 6, 2};TakeSmallest[list, 3]Sort[list, NumericalOrder]Comparisons of non-numerical elements effectively follow canonical order:
list = {1, 7, a, 4, 6, 2, b};TakeSmallest[list, 6]Sort[list, Order]Order is the default ordering function for Sort and ReverseSort:
Sort[list]TakeSmallest[data,…] operates at the first level of the input data:
RandomInteger[100, 10]TakeSmallest[%, 3]If the input has several levels, it is still elements of the first level that will be sorted and extracted:
RandomInteger[100, {5, 2}]TakeSmallest[%, 3]Unlike Min, TakeSmallest does not return values at deeper levels:
Min[%%]When different numerical expressions have the same value, their original order will be preserved:
TakeSmallest[{1, 2, 4, 3, 2.}, 3]TakeSmallest[{1, 2., 4, 3, 2}, 3]TakeSmallest[list,n,p] is effectively equivalent to MinimalBy[list,Identity,n,p]:
list = Quantity[RandomReal[10, 5], "Knots"]TakeSmallest[list, 3]MinimalBy[list, Identity, 3, NumericalOrder]Take a list of five dates in the current year:
list = RandomDate[5]Get the two earliest of the dates with TakeSmallest:
TakeSmallest[list, 2]Get the second earliest of the dates with RankedMin:
RankedMin[list, 2]Possible Issues (2)
If fewer than the requested number of elements are present, TakeSmallest will not evaluate:
TakeSmallest[{3, 1, 2}, 5]Use UpTo to get as many elements as possible:
TakeSmallest[{3, 1, 2}, UpTo[5]]If the elements are not comparable, TakeSmallest will not evaluate:
TakeSmallest[{Quantity[1, "Hour"], Quantity[5, "Joules"]}, 1]See Also
TakeSmallestBy MinimalBy Min PositionSmallest Sort SortBy NumericalSort NumericalOrder Ordering RankedMin TakeLargest TakeLargestBy
Function Repository: DropSmallest TakeSmaller TakeBefore ParetoListMinima
Text
Wolfram Research (2015), TakeSmallest, Wolfram Language function, https://reference.wolfram.com/language/ref/TakeSmallest.html (updated 2025).
CMS
Wolfram Language. 2015. "TakeSmallest." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/TakeSmallest.html.
APA
Wolfram Language. (2015). TakeSmallest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TakeSmallest.html
BibTeX
@misc{reference.wolfram_2026_takesmallest, author="Wolfram Research", title="{TakeSmallest}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/TakeSmallest.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_takesmallest, organization={Wolfram Research}, title={TakeSmallest}, year={2025}, url={https://reference.wolfram.com/language/ref/TakeSmallest.html}, note=[Accessed: 13-June-2026]}