---
description: A function that sorts message property or a sequence of messages.
---

# Sort Array

### Inputs

Enter an array of strings or numbers into `msg.payload`, by default.

When configured to sort message property, the node sorts array data pointed to by specified message property.

When configured to sort a sequence of messages, it will reorder the messages.

### Outputs

Sorted arrays on `msg.payload`.

![](https://1551505950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mkaq90Au3F8Kz0qIFzO%2Fuploads%2Fgit-blob-076ca20dd04089bb71ea23fe7819f3173b992c6d%2Fimage.png?alt=media)

### Details

The sorting order can be:

* **ascending**,
* **descending**.

For numbers, numerical ordering can be specified by a checkbox.

Sort key can be element value or JSONata expression for sorting property value, or message property or JSONata expression for sorting a message sequence.

When sorting a message sequence, the sort node relies on the received messages to have `msg.parts` set. The split node generates this property, but can be manually created. It has the following properties:

* `id` - an identifier for the group of messages
* `index` - the position within the group
* `count` - the total number of messages in the group

**Note:** This node internally keeps messages for its operation. In order to prevent unexpected memory usage, maximum number of messages kept can be specified. Default is no limit on number of messages.

* `nodeMessageBufferMaxLength` property set in **settings.js**.
