IDENTIFICATION DIVISION.
PROGRAM-ID. COMPARE-STRINGS-IN-ARRAY.
DATA DIVISION.
WORKING-STORAGE SECTION.
78 MAX-ITEMS value 3.
77 i pic 9(2).
01 ARRAY.
05 array-items occurs MAX-ITEMS.
10 item pic x(3).
01 RESULTS.
05 filler pic 9(1).
88 ascending-order value 1 when set to false is 0.
PROCEDURE DIVISION.
main.
move "AA BB CC" to ARRAY
perform strings_are_equal
STOP RUN.
strings_are_equal.
display "array:"
set ascending-order to true
perform varying i from 1 by 1 until i > MAX-ITEMS
if item(i) <> spaces
display function trim(item(i)), " " no advancing
if i < MAX-ITEMS and item(i + 1) <> spaces
if item(i) > item(i + 1)
set ascending-order to false
end-if
end-if
end-if
end-perform
display " "
if ascending-order
display "yes"
else
display "no"
end-if
display " "
.
*> run:
*>
*> array:
*> AA BB CC
*> yes
*>