collation library

Provides locale-sensitive string comparison.

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

  final collation = Collation(locale: Locale('de'));
  final list = ['a', 'ä', 'b'];
  list.sort(collation.compare);
  print(list); // Prints [a, b, ä]
}

Available either as an extension on String, or through the Collation class.

Classes

Collation
Provides locale-sensitive string comparison.
Locale
Representing a Unicode locale identifier.

Enums

CaseFirst
How upper case or lower case letters should be sorted.
Sensitivity
Which differences in the strings should lead to non-zero result values. The default is Sensitivity.variant for usage Usage.sort; it's locale dependent for Usage.search.
Usage
Whether to use collation for searching for strings in an array, or rather sorting an array of strings.

Extensions

CollationExt on String