PPWIZARD Manual
[Bottom][Contents][Search][Prev]: SetId()[Next]: Summary()

SortArray()

This is a rexx function provided by PPWIZARD. This routine (like all PPWIZARD extensions) can be used with any operating system supported by PPWIZARD.

This function is used to sort a rexx array. The "array" has numeric indexes with the ".0" element holding the number of elements. The array can hold numbers or strings.

The sort is always ascending. You can use the ReverseArray() routine if required.

The function takes 1 or more parameters as follows:

  1. The name of the array (don't include the dot).

  2. If you wish to sort only over specific columns then the starting column number (first column is 1).

  3. If the optional starting column was specified then this specifies the ending column. If not specified then the rest of the string is used.

  4. This is an optional parameter. Do you want a strict compare? If you do then pass 'Y'. A strict compare does not ignore leading and trailing whitespace, however it won't correctly sort numbers.

The routine returns the number of items in the array.

If you are sorting a very large array with a fixed known name then you might wish to have a look at the faster and more powerful PPWSORT.H header file.

Silly Example

    ;--- Set up the array ------------------------
    #evaluate ''               \
              ^                \
                A.1 = "ASDFG"; \
                A.2 = "4123";  \
                A.3 = "61743"; \
                A.4 = "1678";  \
                A.0 = 4;       \
              ^
    
    ;--- Sort array & display --------------------
    #evaluate '' ^call SortArray "A"^
    #evaluate '' ^do I = 1 to A.0; say '"'a.i'"'; end; say ''^
    
    ;--- Sort array (start column 3) & display ---
    #evaluate '' ^call SortArray "A", 3^
    #evaluate '' ^do I = 1 to A.0; say '"'a.i'"'; end;
    


[Top][Contents][Search][Prev]: SetId()[Next]: Summary()

PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Tuesday January 02 2001 at 7:37am