public class NaturalSortComparator extends Object implements Comparator<CharSequence>
NaturalSortComparator
is a fast comparator for sorting a
collection of Strings in a human readable fashion.
This implementation considers sequences of digits to be positive integer values, '.' does not indicate a decimal value nor '-' a negative one. As a result, 12345.12345 will sort higher than 12345.5432 and -12346 will sort higher than 12345.
it does work well for sorting software versions e.g. camel-2.2.0 sorting higher than camel-2.1.0
Modifier and Type | Class and Description |
---|---|
static class |
NaturalSortComparator.Order |
Constructor and Description |
---|
NaturalSortComparator() |
NaturalSortComparator(NaturalSortComparator.Order order) |
Modifier and Type | Method and Description |
---|---|
int |
compare(CharSequence first,
CharSequence second) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals
public NaturalSortComparator()
public NaturalSortComparator(NaturalSortComparator.Order order)
public int compare(CharSequence first, CharSequence second)
compare
in interface Comparator<CharSequence>
Apache Camel