Home > Enterprise >  Locale-sensitive string sort in Dart
Locale-sensitive string sort in Dart

Time:10-07

I need to sort a List<String>. Its elements might contain non-ASCII characters (think é, ž, Æ, ...). Is there a way to do this in Dart while being locale-aware?

Something like localeCompare in Javascript.

Some examples:

Czech (cs_CZ)

List<String> czechWords = ['čeština', 'cvrček', 'chleba',];

// expected after calling a localizedSort() or similar method

List<String> czechWordsSorted = ['cvrček', 'čeština', 'chleba',];

CodePudding user response:

The Dart platform libraries do not currently have any locale-specific string sorting or comparison functionality.

  • Related