Package com.complexible.common.util

# Class AlphaNumericComparator<T>

java.lang.Object
com.complexible.common.util.AlphaNumericComparator<T>

All Implemented Interfaces:
  `Comparator<T>`

public class AlphaNumericComparator<T> extends Object implements Comparator<T>
This is a comparator to perform a mix of alphabetical+numeric comparison. For example, if there is a list {"test10", "test2", "test150", "test25", "test1"} then what we generally expect from the ordering is the result {"test1", "test2", "test10", "test25", "test150"}. However, standard lexigraphic ordering does not do that and "test10" comes before "test2". This class is provided to overcome that problem. This functionality is useful to sort the benchmark files (like the ones in in DL-benchmark-suite) from smallest to the largest. Comparisons are done on the String values returned by toString() so care should be taken when this comparator is used to sort arbitrary Java objects.

Author:
  Evren Sirin

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final AlphaNumericComparator<Object>`
  `CASE_INSENSITIVE`
  Deprecated.
  Use `caseInsensitive()` instead
  `static final AlphaNumericComparator<Object>`
  `CASE_SENSITIVE`
  Deprecated.
  Use `caseSensitive()` instead

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T> AlphaNumericComparator<T>`
  `caseInsensitive()`
  `static <T> AlphaNumericComparator<T>`
  `caseSensitive()`
  `int`
  `compare(T o1, T o2)`
  `static <T> AlphaNumericComparator<T>`
  `getInstance(boolean caseSensitive)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.util.Comparator

  `equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- ## Field Details

  - ### CASE_SENSITIVE

    @Deprecated public static final AlphaNumericComparator<Object> CASE_SENSITIVE
    Deprecated.
    Use `caseSensitive()` instead
    A static instantiation of a case sensitive AlphaNumericComparator

  - ### CASE_INSENSITIVE

    @Deprecated public static final AlphaNumericComparator<Object> CASE_INSENSITIVE
    Deprecated.
    Use `caseInsensitive()` instead
    A static instantiation of a case insensitive AlphaNumericComparator

- ## Method Details

  - ### caseSensitive

    public static <T> AlphaNumericComparator<T> caseSensitive()

  - ### caseInsensitive

    public static <T> AlphaNumericComparator<T> caseInsensitive()

  - ### getInstance

    public static <T> AlphaNumericComparator<T> getInstance(boolean caseSensitive)

  - ### compare

    public int compare(T o1, T o2)
    Specified by:
      `compare` in interface `Comparator<T>`