A comparator for Strings that imposes a more "human" order on Strings. Modeled on the way the Mac OS X Finder orders file names, it breaks the Strings into segments of non-numbers and numbers (e.g. Foo123Bar into 'Foo', 123, 'Bar') and compares the segments from each String one at a time.
The following rules are applied when comparing segments:
If two Strings are identical after analyzing them in a segment-at-time manner then lhs.compareTo(rhs) will be invoked to ensure that the result provided by the comparator is reflexive (i.e. compare(x,y) = -compare(y,x)) and agrees with String.equals() in all cases.
As an example, the following list of Strings is presented in the order in which the comparator will sort them:
|
|