This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Documentation / Mathematica / Built-in Functions / Numerical Computation / Data Manipulation /

Sort

FilledSmallSquare Sort[list] sorts the elements of list into canonical order.

FilledSmallSquare Sort[list, p] sorts using the ordering function p.

FilledSmallSquare Example: Sort[b, c, a] LongRightArrow.

FilledSmallSquare The canonical ordering used by Mathematica is described in Section A.3.9.

FilledSmallSquare Sort[list, p] applies the function p to pairs of elements in list to determine whether they are in order. The default function p is OrderedQ[{#1, #2}]&.

FilledSmallSquare Example: Sort[4, 1, 3, Greater] LongRightArrow.

FilledSmallSquare Sort can be used on expressions with any head, not only List.

FilledSmallSquare See Section 1.8.9, Section 1.8.11 and Section 2.2.10.

FilledSmallSquare See also: Ordering, Order, OrderedQ, Orderless, Median, Quantile.

FilledSmallSquare New in Version 1.

Further Examples