Package: org.codehaus.groovy.runtime

## [Java] Class NumberAwareComparator<T>

- org.codehaus.groovy.runtime.NumberAwareComparator

- All Implemented Interfaces and Traits:
    Comparator, Serializable

      public class NumberAwareComparator<T>
      extends Object
      implements Comparator, Serializable

  Compares two objects using Groovy's friendly comparison algorithm, i.e. handles nulls gracefully (nul being less than everything else) and performs numeric type coercion if required.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `NumberAwareComparator()`
    `NumberAwareComparator(boolean ignoreZeroSign)` Since: 3.0.8

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public int` | `compare(T o1, T o2)` Compares two values using Groovy comparison semantics with numeric coercion.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public NumberAwareComparator()

    - #### public NumberAwareComparator(boolean ignoreZeroSign)

      Since:
        3.0.8

  - ### Method Detail

    - #### public int compare(T o1, T o2)

      Compares two values using Groovy comparison semantics with numeric coercion.

      Parameters:
        `o1` - the first value to compare
        `o2` - the second value to compare
      Returns:
        a negative integer, zero, or a positive integer if o1 is less than, equal to, or greater than o2 according to Groovy semantics