10000 [Finder] Described "use natural sort" option · symfony/symfony-docs@0d38d1b · GitHub
[go: up one dir, main page]

Skip to content

Commit 0d38d1b

Browse files
committed
[Finder] Described "use natural sort" option
1 parent 1abac5c commit 0d38d1b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

components/finder.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,22 @@ 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+
To sort by name using `natural sort order`_ algorithm,
174+
pass ``true`` as the first argument of ``sortByName()`` method.
175175

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

178178
$finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) {
179179
return strcmp($a->getRealPath(), $b->getRealPath());
180180
});
181181

182+
.. note::
183+
184+
Notice that the ``sort*`` methods need to get all matching elements to do
185+
their jobs. For large iterators, it is slow.
186+
182187
File Name
183188
~~~~~~~~~
184189

@@ -320,8 +325,9 @@ The contents of returned files can be read with
320325
// ...
321326
}
322327

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
328+
.. _strtotime: https://php.net/manual/en/datetime.formats.php
329+
.. _protocol: https://php.net/manual/en/wrappers.php
330+
.. _Streams: https://php.net/streams
331+
.. _IEC standard: https://physics.nist.gov/cuu/Units/binary.html
332+
.. _Packagist: https://packagist.org/packages/symfony/finder
333+
.. _`natural sort order`: https://en.wikipedia.org/wiki/Natural_sort_order

0 commit comments

Comments
 (0)
0