Policies & Guidelines

SORT

Sort an array of strings or numbers

Description

Returns an array containing all the values in the given array of strings or numbers, sorted in order. The function ignores letter case.

Function signature

SORT(array: Array<number>|Array<string>, order: String = asc) => Array

Parameter

Description

Array

Array to sort

Order

Order to sort in ("asc" for ascending, "desc" for descending)

Examples

array = [10,1,2,6,-1,10,12]
textArray = ["ABCD","CC","bb","AA","a","aa","abcd"]

Formula

Return value

SORT(array)

[-1,1,2,6,10,10,12]

SORT(array, "desc")

[12,10,10,6,2,1,-1]

SORT(textArray)

["a","AA","aa","ABCD","abcd","bb","CC"]