Skip to content

Commit aeefc87

Browse files
committed
minor #17131 [Finder] Add case insensitive sort (hmoreau)
This PR was squashed before being merged into the 6.2 branch. Discussion ---------- [Finder] Add case insensitive sort Add a new sortByCaseInsensitiveName() method to have case insensitive sorting results. Like the sortByName(), pass true as its argument to use PHP's case insensitive natural sort order algorithm instead. Related to symfony/symfony#46126 PR Replace #16735 PR Commits ------- df9281f [Finder] Add case insensitive sort
2 parents 04a65f6 + df9281f commit aeefc87

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

components/finder.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,20 +339,24 @@ Sorting Results
339339
Sort the results by name, extension, size or type (directories first, then files)::
340340

341341
$finder->sortByName();
342+
$finder->sortByCaseInsensitiveName();
342343
$finder->sortByExtension();
343344
$finder->sortBySize();
344345
$finder->sortByType();
345346

346347
.. versionadded:: 6.2
347348

348-
The ``sortByExtension()`` and ``sortBySize()`` methods were introduced in Symfony 6.2.
349+
The ``sortByCaseInsensitiveName()``, ``sortByExtension()`` and ``sortBySize()`` methods were introduced in Symfony 6.2.
349350

350351
.. tip::
351352

352353
By default, the ``sortByName()`` method uses the :phpfunction:`strcmp` PHP
353354
function (e.g. ``file1.txt``, ``file10.txt``, ``file2.txt``). Pass ``true``
354355
as its argument to use PHP's `natural sort order`_ algorithm instead (e.g.
355356
``file1.txt``, ``file2.txt``, ``file10.txt``).
357+
358+
The ``sortByCaseInsensitiveName()`` method uses the case insensitive :phpfunction:`strcasecmp` PHP function.
359+
Pass ``true`` as its argument to use PHP's case insensitive `natural sort order`_ algorithm instead (the :phpfunction:`strnatcasecmp` PHP function)
356360

357361
Sort the files and directories by the last accessed, changed or modified time::
358362

0 commit comments

Comments
 (0)