org.apache.camel.component.zookeeper
Class NaturalSortComparator

java.lang.Object
  extended by 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
static class NaturalSortComparator.Order
           
 
Constructor Summary
NaturalSortComparator()
           
NaturalSortComparator(NaturalSortComparator.Order order)
           
 
Method Summary
 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
 

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 interface Comparator<CharSequence>


Apache Camel