Sorted array collections are a dynamically sized, sorted collection of components that can be located by indexing. Indexing is always relative to 1.
In this example a form invokes a reusable part that returns a an array collection that has been sorted into the order you requested.  The example also uses an employee reusable part which is used to store employee details.
Type in the name of the field on which you want the list sorted and then click the "Get List" Push button to display the sorted list. The fields you can sort by are EMPNO, SURNAME, GIVENAME, POSTCODE, SALARY, and DEPTMENT.

Define the Collection and Adding Items to It
A sorted array collection is defined In the reusable part used to sort the employees. Employee details are retrieved from file PSLMST,  #SortedEmployee objects are created based on the #Employee object and assigned the retrieved employee details. The collection is then filled with the #SortedEmployee objects:
Set_Ref Com(#SortedEmployeeList) To(*Create_as #Prim_SACO<#Employee>)
Select Fields(#EMPNO #GIVENAME #SURNAME #DEPTMENT #SALARY #POSTCODE) From_File(PSLMST)
Set_Ref Com(#SortedEmployee) To(*Create_as #Employee)
Set Com(#SortedEmployee) Pempno(#Empno) Pgivename(#GiveName) Psurname(#Surname) Psalary(#Salary) Pdepartment(#Deptment) Ppostcode(#PostCode)
Invoke Method(#SortedEmployeeList.Insert) Item(#SortedEmployee)
Endselect
As every item is added to the collection, the Compare event is triggered. This event is used to provide the logic for sorting the collection. #ObjectEmployee and #SubjectEmployee objects are created to be used as the Object and #Subject parameters to compare the employees:
Evtroutine Handling(#SortedEmployeeList.Compare) Object(#Object) Subject(#Subject) Result(#Result)
Define_Com Class(#Employee) Name(#ObjectEmployee) Reference(*Dynamic)
Define_Com Class(#Employee) Name(#SubjectEmployee) Reference(*Dynamic)