# numeric::sort

Sort a numerical list

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```numeric::sort(`list`)
```

## Description

`numeric::sort(list)` sorts the elements in `list`.

The elements of the list are sorted such that their real parts are descending. Elements with the same real part are sorted from large absolute value to small absolute value. In case of a tie (i.e., two elements form a complex conjugate pair), the element with positive imaginary part comes first.

The elements of the list are converted to floating-point numbers via `float`. Elements that cannot be converted lead to an error.

This function is used to sort the return values of `numeric::eigenvalues`, `numeric::eigenvectors`, `numeric::polyroots`, `numeric::singularvalues`, and `numeric::singularvectors`.

## Environment Interactions

The function is sensitive to the environment variable `DIGITS`.

## Examples

### Example 1

The elements in the sorted list have descending real parts:

`numeric::sort([1, 2.0, I, -3, -I, PI, sqrt(2)])`

In the following example, the sorting criterion does not seem to be satisfied. Elements with the same real part are supposed to be ordered from large absolute values to small absolute values:

```x := sin(PI/3): L := numeric::sort([x, sin(float(PI/3)) - I, x + I])```

This is explained by the fact that the floating-point numbers internally have a more accurate representation than shown on the screen. The real part of the last element is indeed a little bit smaller than the other real parts:

```DIGITS := 20: L```

`delete x, L, DIGITS:`

## Parameters

 `list` A list of numbers or numerical expressions

Sorted list.

## See Also

### MuPAD Functions

Was this topic helpful?

Get trial now