# Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.
BUILT-IN WOLFRAM LANGUAGE SYMBOL

# Ordering

Ordering[list]
gives the positions in list at which each successive element of Sort[list] appears.

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

Ordering[list,-n]
gives the positions of the last n elements of Sort[list].

Ordering[list,n,p]
uses Sort[list,p].

## DetailsDetails

• 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.

## ExamplesExamplesopen allclose all

### Basic Examples  (4)Basic Examples  (4)

Find the ordering that sorts a list:

 In[1]:=
 Out[1]=

Apply the ordering:

 In[2]:=
 Out[2]=

Find the positions of the 4 smallest elements in a list:

 In[1]:=
 Out[1]=

Find the position of the largest element:

 In[1]:=
 Out[1]=

Find the ordering of values in an Association:

 In[1]:=
 Out[1]=