sort

Modified on Thu, 9 Jul at 10:49 AM

sort

TABLE OF CONTENTS

Sort an array in ascending order

Definition

array sort(array[number]|array[string] $list)

Sorts input in ascending order, or alphabetically when sorting strings.

Parameters

array[number]|array[string] $list

The array to be sorted.

Returns

array

Input array, sorted ascending, alphabetically.

Examples

Transformation
{
  a: sort(['beta', 'gamma', 'alpha']),
  b: sort(['gamma', 'beta', '1']),
  c: sort(`[3, 1.5, 0, 7, -3]`),
  d: sort([`false`,`[]`,`null`,`true`, 'A', 'a'])
}
Result
{
  "a": ["alpha", "beta", "gamma"],
  "b": ["1", "beta", "gamma"],
  "c": [-3, 0, 1.5, 3, 7],
  "d": null
}

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article