Reputation: 2168
I am trying to sort a SimpleSortingVector in BlackBerry that contains french accents. The sorting puts the items with accents at the very end of the list. How do I sort in blackberry that will put the accented characters with unaccented characters. Collator doesn't seem to work because I believe I am building for too low of a JRE version. I'm building for JRE 4.5.0 minimum.
ie
É = E
here is how I sort the vector:
ssv.setSortComparator(new Comparator()
{
public int compare(Object obj1, Object obj2)
{
String value = ((Item) obj1).getText();
String otherValue = ((Item) obj2).getText();
return value.compareTo(otherValue);
}
});
ssv.reSort();
Thanks, DMan
Upvotes: 1
Views: 56
Reputation: 11876
OS 4.5 is a challenge. For OS 7, RIM added a string comparer to StringUtilities that can be configured the way you want:
StringUtilities.compare(String aString1, int aOffset1, int aLength1,
String aString2, int aOffset2, int aLength2,
int aLevel, int aLocale, int aFlags, int aFlagsMask)
Unfortunately, I am not aware of any built-in solutions for earlier versions of BBOS. You can build your own sorting table for French characters, and write a custom comparer if you only need to support French. If you're looking for global compatibility, that will get tedious though.
Upvotes: 2