Class NaturalOrderComparator

java.lang.Object
megamek.common.util.sorter.NaturalOrderComparator
All Implemented Interfaces:
Serializable, Comparator<String>

public class NaturalOrderComparator extends Object implements Comparator<String>, Serializable
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 Details

  • Constructor Details

    • NaturalOrderComparator

      public NaturalOrderComparator()
    • NaturalOrderComparator

      public NaturalOrderComparator(int collatorStrength)
  • Method Details