org.apache.jorphan.util

## Class AlphaNumericKeyComparator

- java.lang.Object
- - org.apache.jorphan.util.AlphaNumericKeyComparator

- All Implemented Interfaces:
    Comparator<Map.Entry<Object,Object>>

      public class AlphaNumericKeyComparator
      extends Object
      implements Comparator<Map.Entry<Object,Object>>

  Comparator for `Map.Entry` Objects, that compares based on their keys only. The keys will be compared in a human readable fashion by trying to parse numbers that appear in the keys as integers and compare those, too.

  Heavily influenced by https://codereview.stackexchange.com/questions/37192/number-aware-string-sorting-with-comparator

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static AlphaNumericKeyComparator` | `INSTANCE`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compare(Map.Entry<Object,Object> o1, Map.Entry<Object,Object> o2)`

    - ### 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

      `comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- - ### Field Detail

    - #### INSTANCE

          public static final AlphaNumericKeyComparator INSTANCE

  - ### Method Detail

    - #### compare

          public int compare(Map.Entry<Object,Object> o1,
                             Map.Entry<Object,Object> o2)

      Specified by:
        `compare` in interface `Comparator<Map.Entry<Object,Object>>`

Copyright © 1998-2022 Apache Software Foundation. All Rights Reserved.