<commit_before>### [Arrays](../) > sort

```js
sort(arr [, ascending])
```

> Sorts an **array of primitive values**.

- <code>arr {array}</code>

The array to sort.

- <code>[ascending] {boolean}</code>

The sorting order. Default is true (ascending).

#### Example
```js
sort(['Delta', 'Omega', 'alpha', 'CHARLIE', 'lorem', 'bravo']); // => ['alpha', 'bravo', 'CHARLIE', 'Delta', 'lorem', 'Omega']
sort(['Delta', 'Omega', 'alpha', 'CHARLIE', 'lorem', 'bravo'], false); // => ['Omega', 'lorem', 'Delta', 'CHARLIE', 'bravo', 'alpha']
sort([4, 6, 2, 9, 100, 321, -2, 99], true); // => [-2, 2, 4, 6, 9, 99, 100, 321]
sort([4, 6, 2, 9, 100, 321, -2, 99], false); // => [321, 100, 99, 9, 6, 4, 2, -2]
sort([4, 6, undefined, 2, 9, -10, 100, 321, -2, null, 99], true); // => [-10, -2, undefined, null, 2, 4, 6, 9, 99, 100, 321]
sort([4, 6, undefined, 2, 9, -10, 100, 321, -2, null, 99], false); // => [321, 100, 99, 9, 6, 4, 2, undefined, null, -2, -10]
```<commit_msg>[ci skip] update docs<commit_after>### [Arrays](../) > sort

```js
sort(arr [, ascending])
```

> Sorts an array (not in place) of **primitive values**.

- `arr {Array}`

The array to sort.

- `[ascending] {Boolean}`

The sorting order. Default is `true` (ascending).

#### Example
```js
sort(['Delta', 'Omega', 'alpha', 'CHARLIE', 'lorem', 'bravo']); // => ['alpha', 'bravo', 'CHARLIE', 'Delta', 'lorem', 'Omega']
sort(['Delta', 'Omega', 'alpha', 'CHARLIE', 'lorem', 'bravo'], false); // => ['Omega', 'lorem', 'Delta', 'CHARLIE', 'bravo', 'alpha']
sort([4, 6, 2, 9, 100, 321, -2, 99], true); // => [-2, 2, 4, 6, 9, 99, 100, 321]
sort([4, 6, 2, 9, 100, 321, -2, 99], false); // => [321, 100, 99, 9, 6, 4, 2, -2]
sort([4, 6, undefined, 2, 9, -10, 100, 321, -2, null, 99], true); // => [-10, -2, undefined, null, 2, 4, 6, 9, 99, 100, 321]
sort([4, 6, undefined, 2, 9, -10, 100, 321, -2, null, 99], false); // => [321, 100, 99, 9, 6, 4, 2, undefined, null, -2, -10]
```
{'fraction_non_alphanumeric': 0.29341627786417834, 'fraction_numerical': 0.11612234318299637, 'mean_word_length': 3.8860759493670884, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '88255', 'n_tokens_mistral': 987, 'n_tokens_neox': 787, 'n_words': 274}