- Published on
Sort internal table
Sort the elements of a table.
Consider the following example, illustrating the sorting of a table (STUDENTS) in descending order based on the AGE field.
WORKING-STORAGE SECTION.
01 STUDENTS-GROUP.
05 STUDENTS OCCURS 50 TIMES.
10 FIRST-NAME PIC X(100).
10 LAST-NAME PIC X(100).
10 AGE PIC 99.
...
PROCEDURE DIVISION.
SORT STUDENTS DESCENDING AGE.