public class AlphanumericComparator extends Object implements Comparator<CharSequence>
This source can be found at https://github.com/sawano/alphanumeric-comparator
Note: this algorithm does not take into account numeric notation such as decimals, negative numbers, scientific notation etc.
| Constructor and Description |
|---|
AlphanumericComparator()
Creates a comparator that will use lexicographical sorting of the non-numerical parts of the compared strings.
|
AlphanumericComparator(Collator collator)
Creates a comparator that will use the given collator to sort the non-numerical parts of the compared strings.
|
AlphanumericComparator(Locale locale)
Creates a comparator that will use locale-sensitive sorting of the non-numerical parts of the compared strings.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compare(CharSequence s1,
CharSequence s2) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic AlphanumericComparator()
public AlphanumericComparator(Locale locale)
locale - the locale to usepublic AlphanumericComparator(Collator collator)
collator - the collator to usepublic int compare(CharSequence s1, CharSequence s2)
compare in interface Comparator<CharSequence>Copyright © 2014. All rights reserved.