Hi Ranchers,
This is regarding the sorting issue I am facing with java.text.Collator class.
I am using java.text.Collator to sort the Strings which can have English/Non-English characters.
If I pass list with two values {'a' , 'A'}, the output for me should be {'A', 'a'}.
I tried by setting strength as PRIMARY, SECONDARY, TERITIARY, IDENTICAL but it has not worked for me.
Also, I have tried RuleBasedCollator where I can define which character should come after the other like A < B < ....Z < a < b <c...; But this option force me to provide the rules for all the languages that we support. So, I cannot use this option.
Sampe code:
---------------
import java.util.*;
import java.text.Collator;
class Test {
public static void main(String[] args) {
ArrayList><String> list = new ArrayList<String>();
list.add("a");
list.add("A");
Collections.sort(list, Collator.getInstance());
System.out.println(list);
}
}
Output: {a, A}
Expected Output: {A, a}
Could some one suggest me how to get case-sensitive sorting using Collator.
Thanks,
Ravindra