8000 [Finder] Described "use natural sort" option by vyshkant · Pull Request #9671 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Finder] Described "use natural sort" option #9671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Expanded the explanation a bit
  • Loading branch information
javiereguiluz authored Jun 1, 2018
commit 96498001740f7757cdff9788970b47f97fd6ec42
9 changes: 7 additions & 2 deletions components/finder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,13 @@ Sort the result by name or by type (directories first, then files)::

.. tip::

To sort by name using `natural sort order`_ algorithm,
pass ``true`` as the first argument of ``sortByName()`` method.
By default, the ``sortByName()`` method uses the :phpfunction:`strcmp` PHP
function (e.g. ``file1.txt``, ``file10.txt``, ``file2.txt``). Pass ``true``
as its argument to use PHP's `natural sort order`_ algorithm instead (e.g.
``file1.txt``, ``file2.txt``, ``file10.txt``).

.. versionadded:: 4.2
The option to use the natural sort order was introduced in Symfony 4.2.

You can also define your own sorting algorithm with ``sort()`` method::

Expand Down
0