(I use Java)
I want to sort a sublist of objects by a property using a Collator so that is sorted by alphabetical order but ignoring accents. Problem is I have tried different things and none work.
This sorts the sublists but doesn't ignore accents:
newList.subList(0, 5).sort(Comparator.comparing(element -> element.getValue()));
This is the collator I want to use:
Collator spCollator = Collator.getInstance(new Locale("es", "ES"));
I expect the output to be a sublist sorted by alphabetical order by the property which you can access with .getValue() ignoring the accents.
Collator is also a Comparator. If the elements are String:
If the elements are custom Object:
Or the lambda way: