compareToIgnoringCase method

int compareToIgnoringCase(
  1. String other
)

Returns a value according to the contract for Comparator indicating the ordering between this and other, ignoring letter case.

Example:

'ABC'.compareToIgnoringCase('abd'); // negative value
'ABC'.compareToIgnoringCase('abc'); // zero
'ABC'.compareToIgnoringCase('abb'); // positive value

NOTE: This implementation relies on String.toLowerCase, which is not locale aware. Therefore, this method is likely to exhibit unexpected behavior for non-ASCII characters.

Implementation

int compareToIgnoringCase(String other) =>
    toLowerCase().compareTo(other.toLowerCase());