Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteee653f

Browse files
committed
minor#9671 [Finder] Described "use natural sort" option (vyshkant, javiereguiluz)
This PR was merged into the master branch.Discussion----------[Finder] Described "use natural sort" optionAdded description for new `$useNaturalSort` option of `Finder::sortByName()` method.Commits-------9649800 Expanded the explanation a bit0d38d1b [Finder] Described "use natural sort" option
2 parents179c06f +9649800 commiteee653f

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

‎components/finder.rst‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,27 @@ Sort the result by name or by type (directories first, then files)::
168168

169169
$finder->sortByType();
170170

171-
..note::
171+
..tip::
172172

173-
Notice that the ``sort*`` methods need to get all matching elements to do
174-
their jobs. For large iterators, it is slow.
173+
By default, the ``sortByName()`` method uses the:phpfunction:`strcmp` PHP
174+
function (e.g. ``file1.txt``, ``file10.txt``, ``file2.txt``). Pass ``true``
175+
as its argument to use PHP's `natural sort order`_ algorithm instead (e.g.
176+
``file1.txt``, ``file2.txt``, ``file10.txt``).
177+
178+
..versionadded::4.2
179+
The option to use the natural sort order was introduced in Symfony 4.2.
175180

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

178183
$finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) {
179184
return strcmp($a->getRealPath(), $b->getRealPath());
180185
});
181186

187+
..note::
188+
189+
Notice that the ``sort*`` methods need to get all matching elements to do
190+
their jobs. For large iterators, it is slow.
191+
182192
File Name
183193
~~~~~~~~~
184194

@@ -320,8 +330,9 @@ The contents of returned files can be read with
320330
// ...
321331
}
322332

323-
.. _strtotime:https://php.net/manual/en/datetime.formats.php
324-
.. _protocol:https://php.net/manual/en/wrappers.php
325-
.. _Streams:https://php.net/streams
326-
.. _IEC standard:https://physics.nist.gov/cuu/Units/binary.html
327-
.. _Packagist:https://packagist.org/packages/symfony/finder
333+
.. _strtotime:https://php.net/manual/en/datetime.formats.php
334+
.. _protocol:https://php.net/manual/en/wrappers.php
335+
.. _Streams:https://php.net/streams
336+
.. _IEC standard:https://physics.nist.gov/cuu/Units/binary.html
337+
.. _Packagist:https://packagist.org/packages/symfony/finder
338+
.. _`natural sort order`:https://en.wikipedia.org/wiki/Natural_sort_order

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp