---
title: "sort array by length · RUAL Documentation"
description: "Sorts an array based on the length of the elements."
canonical: https://docs.rual.nl/block-types/array/array_sort_length
language: en
---

# sort array by length

This block is part of the [`array`](https://docs.rual.nl/block-types/array) group and was last modified in core [`v10.4.28`](https://docs.rual.nl/core-versions/100428).

Sorts an array based on the length of the elements.

- Array required `array` The array to be sorted.

- short - long `condition` Sort the array from short to long if set to true.

Default `false`

- array `array` The array with the items sorted based on length.

Stable-sorts a COPY of the array by the character length of each item's string representation (non-strings are stringified first); the input is not mutated. condition=true sorts short to long; unfilled or false sorts LONG TO SHORT - descending is the default.

[sort array by length](https://docs.rual.nl/block-types/array/array_sort_length) orders an array by the text length of its items, shortest first by default. Here the sorted result feeds [get first item](https://docs.rual.nl/block-types/array/array_first_item), which picks the shortest value. The condition pin flips the direction when wired.

![Studio canvas example for the sort array by length block: sorting values short to long.](https://docs.rual.nl/canvas-examples/array_sort_length.png)

### Version history

Introduced in [`v10.4.28`](https://docs.rual.nl/core-versions/100428).
