Package megamek.common.util.sorter
Class NaturalOrderComparator
java.lang.Object
megamek.common.util.sorter.NaturalOrderComparator
- All Implemented Interfaces:
Serializable,Comparator<String>
A comparator that compares the inputs based on natural sort order.
Natural sort order is an easier to parse format that counts multi-digit numbers atomically (as a single number)
Windows File Explorer uses this format for files as it is more human-friendly, but ASCII sort order is more common in computer programs because of the ease of programming in that order.
To showcase how this works, below is an example: The list of Strings { "Atlas 0", "Atlas 15", "Atlas 2", "Atlas 1", "Atlas 5" } would be sorted into { "Atlas 0", "Atlas 1", "Atlas 2", "Atlas 5", "Atlas 15" } instead of ASCII's { "Atlas 0", "Atlas 1", "Atlas 15", "Atlas 2", "Atlas 5" }
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
NaturalOrderComparator
public NaturalOrderComparator() -
NaturalOrderComparator
public NaturalOrderComparator(int collatorStrength)
-
-
Method Details
-
compare
- Specified by:
comparein interfaceComparator<String>
-