COBCH1809 keyword is not a suitable SORT key type - does not implement IComparable Comparable interface

When sorting a managed array, if the type of the sort key (or of the array element if no key is explicitly specified) is final, meaning that it cannot be sub-typed, then that type must implement the java.lang.Comparable interface when compiling for JVM. If the type is not final, and if that type does not implement the correct interface, then the sort might cause an exception at run time.

Resolution:

Correct the code; then recompile.

Example:

The following example shows incorrect coding that throws a run-time error, and that throws a compile time error.

           declare array1 as Type A occurs 2
           set array1(1) to new A
           set array1(2) to new A
           sort array1       *> Compiles cleanly but gives error at run time
           declare array2 as Type B occurs 2
           set array2(1) to new B
           set array2(2) to new B
           sort array2       *> Gives compile time error
       end program.
       class-id A.
       end class.
       class-id B final.
       end class.