Skip to content

Sort Array ​

What It Does ​

Arranges items in a list in a specific order, either ascending or descending. It can sort by a specific property for complex objects, helping to organize collections.

Inputs ​

NameDescriptionTypeRequired
arrayThe list to be sortedListYes
orderDirection of sort ("asc" or "desc")TextNo
sortByProperty name to sort by (for object elements)TextYes

Outputs ​

NameDescriptionType
valueThe sorted listList

Sort Array Example

How to Use It ​

  1. Drag the Sort Array node into your graph.
  2. Connect your list (like [16, 18, 21, 24, 28, 32]) to the "array" input.
  3. Set "sortBy" to the property to sort on (e.g., "value").
  4. Optionally change "order" to "desc" for descending order (default is "asc").

Tips ​

  • For simple lists (numbers or strings), use an empty string for the "sortBy" value.
  • The sort is stable, meaning equal items maintain their relative order.

See Also ​

  • Reverse Array: For simply flipping the order of items without sorting.
  • Array Filter: For selecting items rather than reordering them.

Use Cases ​

  • Color Organization: Sort colors by brightness, hue, or other properties.
  • Token Prioritization: Arrange design tokens by their importance or frequency of use.
  • Size Sequencing: Order spacing or sizing tokens from smallest to largest for consistent scales.