By sleitner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
12.1.x
Introduced in version:
12.1.0
Issue links:
Description:
The new function Drupal\Core\Utility\NaturalSort::strnatcasecmp() is a generic sort helper for language-dependent string comparisons using a "natural order" algorithm as drop-in replacement for the PHP function strnatcasecmp. If the PHP intl extension is installed it uses Collator::compare(), otherwise it falls back to strnatcasecmp()
Number based strings will also sort in their natural order now as well: e.g. 10 will come after 9.
Replace:
strnatcasecmp($a_string, $b_string);
With:
NaturalSort::strnatcasecmp($a_string, $b_string);
Impacts:
Module developers