<<

Contents

Search

>>

 

SORT_ARRAY

 

 

Instruction

 

 

Syntax:

SORT_ARRAY(<Array>, <Count>, <Ascending/Descending>, <Upper/Lower Case>, <Position> [,<Separator>])

 

<Array>

= <STRING-VARIABLE>

<Count>

= <NUM-EXPRESSION>

<Ascending/Descending>

= <NUM-EXPRESSION>

<Upper/Lower Case>

= <NUM-EXPRESSION>

<Position>

= <NUM-EXPRESSION>

<Separator>

= <STRING-EXPRESSION>

 

 

Meaning:

SORT_ARRAY sorts a one-dimensional alphanumeric array.

 

<Count> specifies the number of elements in <Array> that are to be sorted. 

Note: Sorting starts with element no. 1. Element no. 0 is ignored. 

 

<Ascending/Descending> specifies whether the sorting order is ascending or descending. If <Ascending/Descending> > 0, the order is ascending, otherwise it is descending. 

 

<Upper/Lower Case> specifies whether small and capital letters are differentiated with sorting. If <Upper/Lower Case> = 0, there is no differentiation between small and capital letters, otherwise there is. 

 

<Position> specifies the character at which sorting starts in the array elements. Counting starts from 1.  <Position> < 1 is equivalent to 1.

 

If a <Separator> <> ²² is specified, the program presumes that the entries in the array elements are separated by a separator. In this case <Position> specifies the number of a substring (SUBSTR$) that is to be sorted.

 

Parameter:

Array

Name of the variable of a one-dimensional String Array

Count

Number of elements in <Array> that are to be used.

Ascending/Descending

> 0: Ascending sorting order. 

Otherwise: Descending sorting order.

Upper/Lower Case

Specifies whether small and capital letters are differentiated with sorting.

Position

Specifies the position from which the elements are sorted.

Separator

If a separator <> ²² is specified, a substring is sorted in the array elements.

 

Sample:

DIM T$(100)

 

T$(1) = ²Smith²

T$(2) = ²McDonald²

T$(3) = ²Carter²

 

SORT_ARRAY(T$,3,1,0,1)

 

// T$(1) contains: ²Carter²

// T$(2) contains: ²McDonald²

// T$(3) contains: ²Smith²

 

// Sort substring

T$(1) = ²Smith;John;Munic²

T$(2) = ²McDonald;Francis;Berlin²

T$(3) = ²Carter;Joseph;San Francisco²

 

SORT_ARRAY(T$,3,1,0,3,²;²)

 

// T$(1) contains: ²McDonald;Francis;Berlin²

// T$(2) contains: ²Smith;John;Munic²

// T$(3) contains: ²Carter;Joseph;San Francisco²

 

See also:

DIM

SUBSTR$

SORT_FILE