Product SiteDocumentation Site

5.3.18.3. Builtin Comparators

Rexx includes a number of built-in Comparators for common sorting operations.
Comparator
Base comparator. The Comparator class just uses the compareTo method of the first argument to generate the result. Using sortWith and a Comparator instance is equivalent to using the sort method and no comparator.
DescendingComparator
The reverse of the Comparator class. The DescendingComparator can be used to sort items in descending order.
InvertingComparator
The InvertingComparator will invert the result returned by another Comparator instance. This comparator can be combined with another comparator instance to reverse the sort order.
CaselessComparator
Like the base comparator, but uses the caselessCompareTo method to determine order. The String class implements caselessCompareTo, so the CaselessComparator can be used to sort arrays of strings independent of case.
ColumnComparator
The ColumnComparator will sort string items using specific substrings within each string item. If sorting is performed on multiple column positions, the stableSortWith method is recommended to ensure the results of previous sort operations are retained.
CaselessColumnComparator
Like the ColumnComparator, but the substring comparisons are done independently of case.
NumericComparator
Performs comparisons of strings using numeric comparison rules. Use the NumericComparator to sort collections of numbers.