ADELIA |
VADELIA |
SADELIA |
WADELIA |
EADELIA |
(I/B) |
(I/B) (C/S) |
(B) (S) |
(I/B) (C/S) |
(B) (C/S) |
Section for use
All
Syntax
SORT Array
Description
This instruction sorts the elements of an array Array in ascending order.
It can only be executed upon an array without an index number.
This must be a one-dimensional array.
Warning: This instruction cannot be used at the same time as the SORT_D instruction on the same array when RPG language is generated.
Example
* Routine to print items by DESCRIPTION in alphabetic ascending order
* ARR_ITEMS has 99 elements
*
ARR_ITEMS = *BLANK
IN = 0
READ ITEMS
DO_WHILE ITEMS EXISTS
IN = IN + 1
ARR_ITEMS(IN) = ITEM_DESC
READ ITEMS
REDO
*
SORT ARR_ITEMS
*
IN = 99 - IN
DO_WHILE IN < 99
IN = IN + 1
ZZ_ITEM_DESC = ARR_ITEMS(IN)
PRINT ITEM_FORMAT
REDO
Result might look like:
COAT
HAT
SHIRT
SHOE
SWEATER
TIE
TROUSERS