Class AlphanumComparator<T>

java.lang.Object
io.goobi.viewer.controller.sorting.AlphanumComparator<T>
Type Parameters:
T - the type of elements to be compared
All Implemented Interfaces:
Serializable, Comparator<T>

public class AlphanumComparator<T> extends Object implements Comparator<T>, Serializable
Comparator implementing the Alphanum algorithm, which sorts strings containing numbers in natural numeric order rather than ASCII order, with locale-aware collation and optional translation support.
See Also:
  • Constructor Details

  • Method Details

    • compare

      public int compare(T o1, T o2)
      Specified by:
      compare in interface Comparator<T>
      Parameters:
      o1 - first object to compare
      o2 - second object to compare
      Returns:
      a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
    • normalizeString

      public static String normalizeString(String s, String ignoreChars)
      Parameters:
      s - String to normalize
      ignoreChars - Optional string containing leading characters to remove from the string
      Returns:
      Cleaned-up string for comparison