Collator plus Comparator

I have a collection of beans OptionItemDTO (properties label and value) and I'm currently using something like this to sort by label:

Collections.sort(combo, new LabelComparator())

The problem is that it does not sort stressed vowels (my locale is spanish).

According to this document I must use a Collator class.

But if I use the sort with collator, I can't use the comparator (and vice-versa). Any ideas?

Thanks in advance!


Your LabelComparator should delegate to a Collator to compare the labels of your DTOs:

public int compare(OptionItemDTO dto1, OptionItemDTO dto2) {
    return, dto2.getLabel());

Need Your Help

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.