compareLocale method

int compareLocale(
  1. String other, {
  2. Locale? locale,
})

Compares this string to other in a locale-dependent manner, following the conventions of a Comparator.

The result is negative if this string is ordered before other, positive if this string is ordered after other, and zero if this string and other are ordered equally.

import 'package:intl4x/collation.dart';

void main() {
  print('a'.compareLocale('b')); // Prints -1
  print('ä'.compareLocale('z', locale: Locale('de'))); // Prints -1
  print('ä'.compareLocale('z', locale: Locale('sv'))); // Prints 1
}

For more options, use Collation directly.

Implementation

int compareLocale(String other, {Locale? locale}) =>
    Collation(locale: locale).compare(this, other);