# sort! {#sort}

**Parent topic:**[Functions](../../Functions/category.md)

## Syntax {#syntax}

`sort!(X, [ascending=true])`

## Arguments {#arguments}

**X** is a vector/matrix.

**ascending** \(optional\) is a Boolean scalar indicating whether to sort *X* in ascending order or descending order. The default value is true \(ascending order\).

## Details {#details}

Sort *X* in-place in ascending/descending order.

## Examples {#examples}

```
x=9 1 5;
sort!(x);
x;
// output: [1 5 9]

x.sort!(0);
x;
// output: [9,5,1]
```

