Roboteka
Roboteka · Robots · Sort an array

Sort an array

The "Sort an array" robot orders an array of values ascending or descending in Bitrix24 (Alaio) business processes and robots. It takes a multiple-value field or another robot output; the data type is detected automatically: when every element is numeric the sort is numeric, otherwise strings are compared alphabetically. It returns the sorted array and the element count.

The robot sorts array elements and returns a new ordered list — without it, sorting numbers as strings in a business process produces the wrong order like 1, 10, 2. The input is a multiple-value field or an array from a previous step, the direction (asc — ascending, desc — descending), and the data type: auto picks numeric or string mode automatically, number forces comparing elements as numbers, string compares them as case-insensitive strings in natural order. Typical use cases: order payment amounts before picking the top three; sort a list of names for a letter; arrange string-split results alphabetically. An empty array is returned empty without an error. It returns the sorted array and the element count — use them in the next steps of the business process.

What input parameters does the robot accept?

Parameter Type Required? Default
Array of values string yes
Direction: asc — ascending, desc — descending (default asc) string
Data type: auto / number / string (default auto) string

What does the robot return?

Parameter Type
Sorted array string
Element count int

Scenario: top payments in a manager email

  1. A deal enters the Closed stage
  2. The robot sorts the array of payment amounts in descending order
  3. The sorted array is inserted into the email — the largest payments come first

Related robots