Class NaturalTextComparator

java.lang.Object
com.github.tommyettinger.ds.support.sort.NaturalTextComparator
All Implemented Interfaces:
Comparator<CharSequence>

public class NaturalTextComparator extends Object implements Comparator<CharSequence>
A Comparator that can sort Strings, StringBuilders, and other CharSequences by "natural text order," also called Alphanum sort order. This "unofficial natural order" for text treats groups of digits as one number, and sorts using that one numerical value instead of the lexicographic order that is more commonly used in programming languages. This is based on Grey Panther's code, extending it slightly so that it sorts all upper-case letters before any lower-case letters, in any language with case. You don't construct a new one of these; instead, use CASE_SENSITIVE or CASE_INSENSITIVE to get a predefined immutable instance.