sort array by length

This block is part of the array group and was last modified in core v10.4.28.

sort array by length v10.4.28

Sorts an array based on the length of the elements.

In pins 2
  • Array required
    array

    The array to be sorted.

  • short - long
    condition

    Sort the array from short to long if set to true.

    Default false

Out pins 1
  • 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 orders an array by the text length of its items, shortest first by default. Here the sorted result feeds get 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.

Version history

Introduced in v10.4.28.


Back to array Return to the main group to view all sub-groups Back to array Return to the group to view all blocks within this group