Class NaturalTextComparator
java.lang.Object
com.github.tommyettinger.ds.support.sort.NaturalTextComparator
- All Implemented Interfaces:
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<CharSequence>static final Comparator<CharSequence>static final Comparator<CharSequence>static final Comparator<CharSequence>static final Comparator<CharSequence> -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
INSTANCE
-
CASE_INSENSITIVE
-
CASE_SENSITIVE
-
CASE_INSENSITIVE_OPPOSITE
-
CASE_SENSITIVE_OPPOSITE
-
-
Method Details
-
compare
- Specified by:
comparein interfaceComparator<CharSequence>
-