Statistics - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Statistics

 Sort
 sort numeric data

 Calling Sequence Sort(X, options)

Parameters

 X - options - (optional) equation(s) of the form option=value where option is one of order or unique; specify options for the Sort function

Description

 • The Sort command sorts the elements of X according to their numeric values.
 • The first parameter X is the data set (typically an Array or a list).

Options

 The options argument can contain one or more of the options shown below.
 • order=ascending or descending -- Indicates whether the elements of X should be sorted in the ascending or descending order. The default value is order=ascending.
 • unique=truefalse -- If this option is set to true, all multiple occurrences of elements from X will be removed. The default value is unique=false. Note that if this option is set to unique=true then all elements of X must be of type float.

Notes

 • Although the Sort command accepts non-numeric data, maple must be able to compute floating-point values for all elements in X. If the unique option is set to unique=true all elements in X must be of type numeric.
 • The Sort command creates a copy of the original data.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$
 > $A≔\mathrm{Array}\left(\left[\mathrm{sin}\left(1\right),\mathrm{sin}\left(2.\right),\mathrm{sin}\left(1.\right),\mathrm{sin}\left(3.\right),\mathrm{sin}\left(5.\right),\mathrm{sin}\left(2.\right),\mathrm{sin}\left(3.\right),\mathrm{sin}\left(6.\right)\right]\right)$
 ${A}{:=}\left[\begin{array}{cccccccc}{\mathrm{sin}}{}\left({1}\right)& {0.9092974268}& {0.8414709848}& {0.1411200081}& {-}{0.9589242747}& {0.9092974268}& {0.1411200081}& {-}{0.2794154982}\end{array}\right]$ (1)
 > $B≔\mathrm{Sort}\left(A\right)$
 ${B}{:=}\left[\begin{array}{cccccccc}{-}{0.9589242747}& {-}{0.2794154982}& {0.1411200081}& {0.1411200081}& {0.8414709848}& {\mathrm{sin}}{}\left({1}\right)& {0.9092974268}& {0.9092974268}\end{array}\right]$ (2)
 > $\mathrm{evalf}\left(B\right)$
 $\left[\begin{array}{cccccccc}{-}{0.9589242747}& {-}{0.2794154982}& {0.1411200081}& {0.1411200081}& {0.8414709848}& {0.8414709848}& {0.9092974268}& {0.9092974268}\end{array}\right]$ (3)
 > $\mathrm{Sort}\left(A,\mathrm{order}=\mathrm{descending}\right)$
 $\left[\begin{array}{cccccccc}{0.9092974268}& {0.9092974268}& {\mathrm{sin}}{}\left({1}\right)& {0.8414709848}& {0.1411200081}& {0.1411200081}& {-}{0.2794154982}& {-}{0.9589242747}\end{array}\right]$ (4)
 > $B≔\mathrm{evalf}\left(A\right)$
 ${B}{:=}\left[\begin{array}{cccccccc}{0.8414709848}& {0.9092974268}& {0.8414709848}& {0.1411200081}& {-}{0.9589242747}& {0.9092974268}& {0.1411200081}& {-}{0.2794154982}\end{array}\right]$ (5)
 > $\mathrm{Sort}\left(B,\mathrm{order}=\mathrm{descending},\mathrm{unique}\right)$
 $\left[\begin{array}{ccccc}{0.9092974268}& {0.8414709848}& {0.1411200081}& {-}{0.2794154982}& {-}{0.9589242747}\end{array}\right]$ (6)
 > $l≔\left[\mathrm{sin}\left(1\right),\mathrm{sin}\left(2.\right),\mathrm{sin}\left(1.\right),\mathrm{sin}\left(3.\right),\mathrm{sin}\left(5.\right),\mathrm{sin}\left(2.\right),\mathrm{sin}\left(3.\right),\mathrm{sin}\left(6.\right)\right]$
 ${l}{:=}\left[{\mathrm{sin}}{}\left({1}\right){,}{0.9092974268}{,}{0.8414709848}{,}{0.1411200081}{,}{-}{0.9589242747}{,}{0.9092974268}{,}{0.1411200081}{,}{-}{0.2794154982}\right]$ (7)
 > $\mathrm{ll}≔\mathrm{Sort}\left(l\right)$
 ${\mathrm{ll}}{:=}\left[{-}{0.9589242747}{,}{-}{0.2794154982}{,}{0.1411200081}{,}{0.1411200081}{,}{0.8414709848}{,}{\mathrm{sin}}{}\left({1}\right){,}{0.9092974268}{,}{0.9092974268}\right]$ (8)
 > $\mathrm{evalf}\left(\mathrm{ll}\right)$
 $\left[{-}{0.9589242747}{,}{-}{0.2794154982}{,}{0.1411200081}{,}{0.1411200081}{,}{0.8414709848}{,}{0.8414709848}{,}{0.9092974268}{,}{0.9092974268}\right]$ (9)

 See Also

## Was this information helpful?

 Please add your Comment (Optional) E-mail Address (Optional) What is ? This question helps us to combat spam