Package jmri.util

Class PreferNumericComparator

java.lang.Object
jmri.util.AlphanumComparator
jmri.util.PreferNumericComparator
All Implemented Interfaces:
Comparator<String>

public class PreferNumericComparator
extends AlphanumComparator
Perform an comparison using AlphanumComparator, followed up with a standard String comparison if AlphanumComparator.compare(String, String) returns 0.

If the requirement is that Comparator.compare(Object, Object) return 0 for two numerically identical Strings (i.e. 42 == 0042), use AlphanumComparator, but if the requirement is that Strings should be numerically ordered, but that non-identical representations should be different, (i.e. 42 != 0042, but order should be 3, 4, 5, 42, 0042, 50), use this Comparator, since the standard String comparator will not order numbers correctly.