

Ordering
Details

- In a numerical list, Ordering[list,n] gives the positions of the n smallest elements. Ordering[list,-n] gives the positions of the n largest elements.
- If there are several smallest elements in list, Ordering[list,1] will give only the position of the one that appears first.
- list[[Ordering[list]]] is the same as Sort[list].
- Ordering[list,seq] is equivalent to Take[Ordering[list],seq].
- Ordering[list,UpTo[n]] returns n positions, or as many as are available.
- Ordering[list,All,p] gives the position at which all elements of list appear in Sort[list,p].
- Ordering can be used on expressions with any head, not only List.
Examples
open all close allBasic Examples (4)
Find the ordering that sorts a list:
Find the positions of the 4 smallest elements in a list:
Find the position of the largest element:
Find the ordering of values in an Association:
Scope (4)
Applications (3)
Properties & Relations (2)
See Also
Sort OrderingBy SortBy Max Min RankedMin RankedMax MaximalBy MinimalBy Position OrderedQ Median Order NumericalOrder AlphabeticOrder LexicographicOrder
Function Repository: Ranking
Tech Notes
History
Introduced in 2000 (4.1) | Updated in 2014 (10.0) ▪ 2015 (10.3)
Text
Wolfram Research (2000), Ordering, Wolfram Language function, https://reference.wolfram.com/language/ref/Ordering.html (updated 2015).
CMS
Wolfram Language. 2000. "Ordering." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/Ordering.html.
APA
Wolfram Language. (2000). Ordering. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Ordering.html
BibTeX
@misc{reference.wolfram_2025_ordering, author="Wolfram Research", title="{Ordering}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/Ordering.html}", note=[Accessed: 13-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_ordering, organization={Wolfram Research}, title={Ordering}, year={2015}, url={https://reference.wolfram.com/language/ref/Ordering.html}, note=[Accessed: 13-August-2025]}