Class NaturalSortComparator
- java.lang.Object
-
- org.apache.camel.component.zookeeper.NaturalSortComparator
-
- All Implemented Interfaces:
Comparator<CharSequence>
- Direct Known Subclasses:
SequenceComparator
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NaturalSortComparator.Order
-
Constructor Summary
Constructors Constructor Description NaturalSortComparator()
NaturalSortComparator(NaturalSortComparator.Order order)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(CharSequence first, CharSequence second)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
NaturalSortComparator
public NaturalSortComparator()
-
NaturalSortComparator
public NaturalSortComparator(NaturalSortComparator.Order order)
-
-
Method Detail
-
compare
public int compare(CharSequence first, CharSequence second)
- Specified by:
compare
in interfaceComparator<CharSequence>
-
-