OrderingBy

OrderingBy[list,f]

gives the positions in list at which each successive element of SortBy[list,f] appears.

OrderingBy[list,f,n]

gives the positions in list at which the first n elements of SortBy[list,f] appear.

OrderingBy[list,f,-n]

gives the positions of the last n elements of SortBy[list,f].

OrderingBy[list,f,n,p]

gives positions in list of elements of SortBy[list,f,p].

OrderingBy[f]

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

Details

Examples

open allclose all

Basic Examples  (3)

Find the ordering that sorts a list of strings by their length:

Apply the ordering:

Check that their string lengths are sorted:

Find the positions of the 3 smallest elements by absolute value:

Find the positions of the 3 largest elements by absolute value:

Find the ordering of values in an association:

Scope  (3)

Find the positions of the 3 shortest strings:

Find the positions of the 3 longest strings by ordering according to decreasing lengths:

Find the positions of the smallest to largest complex numbers by modulus:

Using canonical sorts them in a different way:

Use the operator form of OrderingBy:

Wolfram Research (2019), OrderingBy, Wolfram Language function, https://reference.wolfram.com/language/ref/OrderingBy.html.

Text

Wolfram Research (2019), OrderingBy, Wolfram Language function, https://reference.wolfram.com/language/ref/OrderingBy.html.

CMS

Wolfram Language. 2019. "OrderingBy." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/OrderingBy.html.

APA

Wolfram Language. (2019). OrderingBy. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/OrderingBy.html

BibTeX

@misc{reference.wolfram_2023_orderingby, author="Wolfram Research", title="{OrderingBy}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/OrderingBy.html}", note=[Accessed: 29-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_orderingby, organization={Wolfram Research}, title={OrderingBy}, year={2019}, url={https://reference.wolfram.com/language/ref/OrderingBy.html}, note=[Accessed: 29-March-2024 ]}