CollationKey.getSourceString()
import java.text.CollationKey;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
public class MainClass {
public static void main(String[] args) {
// Build a vector of words to be sorted
ArrayList list = new ArrayList();
list.add("m");
list.add("c2");
list.add("e");
list.add("c1");
Collator collate = Collator.getInstance();
CollationKey[] keys = new CollationKey[list.size()];
for (int k = 0; k < list.size(); k ++)
keys[k] = collate.getCollationKey((String)list.get(k));
Arrays.sort(keys);
for (int l= 0;l < keys.length; l++) {
System.out.println(keys[l].getSourceString());
}
}
}
Related examples in the same category