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