Arr1 can be sorted ascending or descending with the SORTA op-code, but the alternate array Arr2 shouldn’t change. From the ILE RPG Language Reference, SORTA (Sort an Array) page:
- If the array is defined as a compile-time or prerun-time array with data in alternating form, the alternate array is not sorted
I wouldn’t use a run-time array like this if I need to sort it in an order different from how it loaded. Either define the arrays as data structure subfields where the data structure itself is dimensioned and load it yourself from the file, or let your run-time arrays load as they are now and copy them into a data structure array.
After you have them in a data structure array, then you can sort the array using SORTA or any other method you choose.
I suppose you could change from Fromfile(abc) to a different file. Perhaps create a LF that presents the records in descending order.
Almost forgot… If the array is loaded in ascending order and you need to display it descending, just start from the bottom (the highest index) and work through to the top (lowest index).
Tom
Discuss This Question: