Package de.undercouch.citeproc.helper
Class AlphanumComparator
- java.lang.Object
-
- de.undercouch.citeproc.helper.AlphanumComparator
-
- All Implemented Interfaces:
java.util.Comparator<java.lang.CharSequence>
public class AlphanumComparator extends java.lang.Object implements java.util.Comparator<java.lang.CharSequence>Performs locale-sensitive comparison of
Strings with numbers to produce a natural order that appears logical to humans.Examples:
compare("Hello", "Hello") = 0 compare("10", "2") = 1 compare("10th", "2nd") = 1 compare("File 10", "File 2") = 1 compare("Manana", "MaƱana") = -1The implementation is loosely based on the Alphanum algorithm by Dave Koelle and the Java implementation released under the MIT license. However, it has been extended to use a
Collatorfor locale-sensitive comparison, and it is also able to compare arbitrarily large numbers.- Author:
- Michel Kraemer
-
-
Constructor Summary
Constructors Constructor Description AlphanumComparator(java.util.Locale locale)Create a new comparator for the given locale
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(java.lang.CharSequence a, java.lang.CharSequence b)
-