SortArray

Description

The SortArray method sorts an array in either ascending or descending order. It can handle arrays of numbers, strings, and two-dimensional arrays (sorting by the first element of each sub-array).

Syntax

public SortArray<T>(
    array: T[],
    count: number = APIConstants.ARRAY_ENTIRE,
    start = 0,
    direction = APIConstants.SORT_ASCENDING
): boolean

Parameters

  • array: The array to be sorted

  • count: Optional. The number of elements to sort. Default is ARRAY_ENTIRE

  • start: Optional. The starting index for sorting. Default is 0

  • direction: Optional. The sort direction (SORT_ASCENDING or SORT_DESCENDING). Default is SORT_ASCENDING

Return Value

Returns a boolean indicating whether the sorting operation was successful. Returns false if the range is invalid.

Example

Last updated