FileDocCategorySizeDatePackage
SpanishSort.javaAPI DocExample1082Fri Mar 30 00:15:36 BST 2001None

SpanishSort

public class SpanishSort extends Object

Fields Summary
Constructors Summary
public SpanishSort()

    Vector v = new Vector();
    v.add("musa");
    v.add("chic");
    v.add("llama");
    v.add("dela");
    v.add("chocolate");
    v.add("banana");
    v.add("crispa");
    v.add("luzca");

    Collator esCollator = Collator.getInstance(new Locale("es","ES"));
    String spanishRules = ((RuleBasedCollator)esCollator).getRules();

    try {
     String traditionalRules = "& C < ch, cH, Ch, CH " +
                               "& L < ll, lL, Ll, LL";
     RuleBasedCollator collate = new RuleBasedCollator(spanishRules + traditionalRules);

     Collections.sort(v, collate);
    } catch (ParseException e) {
     System.out.println("Error parsing rules " + e.toString());
  }

    StringBuffer result = new StringBuffer();
    for (int i= 0;i < v.size(); i++) {
     result.append(v.elementAt(i));
     result.append("\n");
    }
    System.out.println(result);
  
Methods Summary
public static voidmain(java.lang.String[] args)

    new SpanishSort();