sort array by field

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

sort array by field v10.4.28

Sorts the elements of an array by a given key.

In pins 4
  • Array required
    array

    The array to be sorted.

  • sort by
    value

    Sort by the given field. If left empty, it will sort the entire array.

  • A-Z / 1-9 required
    condition

    If true: sort the array in ascending order (A-Z or 1-9). • Hidden when other fields are filled

  • Z-A / 9-1 required
    condition

    Display-only counterpart of asc: this pin is not read. Sorting is descending whenever asc is false or left unwired. • Hidden when other fields are filled

Out pins 1
  • Array
    array

    The sorted array.

Stable-sorts a COPY of the array; the input is not mutated. With sort_by set it sorts object items by that dot-path field, otherwise by the elements themselves. Direction is decided ONLY by the asc pin: true sorts ascending, unfilled or false sorts DESCENDING (the desc pin is display-only). Numbers compare numerically, strings lexicographically ("10" before "2"), a number and a numeric string compare numerically, and null sorts as smallest.

A typical wiring for sort array by field: true feeds the asc pin; group by feeds the array pin; value feeds the sort_by pin; == feeds the desc pin; the array out pin feeds join.

Studio canvas example for the sort array by field block: typical wiring for sort array by field.

Commonly used with

In production blueprints, this block is most often wired together with:

  • true: feeds into this block. Gives the condition true hard-coded.
  • group by: feeds into this block. Groups the elements of the given array by a specified field.
  • join: this block feeds into it. Creates and returns a new string by concatenating all of the elements in this array, separated by void if none provided.
  • splice: this block feeds into it. Removes an item from your given array.
  • create: feeds into this block. Creates a new function that can be executed using the given name.
  • value: feeds into this block. Simply returns the provided value.

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