Comparators serve two fundamental roles in collections. First, comparators let you identify objects when using search protocols for collections. When you ask if an object is a member of a collection, or when your query a collection for the number of occurrences of a collection, a comparator is used to identify collection elements matching the object given as an argument to the query or search function.
The second role played by comparators is ordering. Sorted collections must use some criteria to determine how to order elements internally. For example should a collection of strings (instances of TStandardText) be sorted in ascending lexical order (a, b, c, ...) or in descending lexical order (z, y, x, ...). The same is true for sorted collections of integers (instances of TCollectibleLong). More complicated examples of sorting might include sorting a collection of files by name, date, or size. A different comparator would be required depending on the kind of ordering required. Thus, there is an intimate relationship between collections and comparators.