Interface to Sort Methods

Implement the interface to a sort method for a SortedCollection instance as follows:

 method-id. "sortMethod".

 linkage section
 01 lsElement1               object reference. 
 01 lsElement2               object reference. 
 01 orderResult              pic x comp-5.
  88 element1first           value 1. 
  88 element2first           value 0. 

 procedure division using lsElement1 lsElement2  
                returning orderResult. 
* Code to compare lsElement1 to lsElement2 and set 
* orderResult to determine which element should precede 
* the other. 
    exit method.
 end method "sortMethod". 

Because you pass the method to the collection as a Callback, you can implement it in any object and give it any method name – "sortMethod" is used here as an example.