Skip to content →

Sorted Accented Rows – Vaadin Grid

Last week I noticed that Vaadin doesn’t automatically sort data which has accents:

Naturally, when you are looking for sorting names, something like “√Čloise” should be grouped around other names which start with an “E”. We can accomplish this task by adding a custom sorter. The easiest way I found to account for all letters in the String rather than just the first, was to strip all accents in the String, and perform a String comparison.

First we’ll start with the accent stripping:

Now, we add the custom sorter:

We see that with this combination, we get our desired result:

This method is applied to French accents, however, it should work with other languages as well!

Check out the example here on github.

Published in Tech

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *