Custom String Comparison in Java
2 min readMay 13, 2021
A hidden gem in the standard Java library is the RuleBasedCollator class. It allows you to define custom collation — a set of rules for comparison between different characters in a string — in a flexible way. Your use cases might be one of the following:
- you need to sort strings with uppercase characters with higher or lower priority than lowercase characters;
- you want to set…