sort

fun sort(comparison: (a: T, b: T) -> Int = definedExternally): S(source)

Sorts an array.

Parameters

compareFn

Function used to determine the order of the elements. It is expected to return a negative value if first argument is less than second argument, zero if they're equal and a positive value otherwise. If omitted, the elements are sorted in ascending order.

[11,2,22,1].sort((a, b) => a - b)