Collator Class

Contains methods to get locale-specific instances that can be used for comparisons and sorting. Use the getInstance() method to obtain the Collator instance for a given locale and pass the Collator as the Comparator parameter to the list.sort() method.

System

Because locale-sensitive sorting can produce different results depending on the user running the code, avoid using it in triggers or in code that expects a particular sort order.

This example performs a default list sort and then uses Collator to sort based on the user locale.

The following are methods for Collator.

Perform string comparisons for a given locale.

public Integer compare(String source, String target)

Type: Integer

Gets the Collator instance for the current user’s locale.

public static System.Collator getInstance()

Type: Collator Class