]> _ Git - cubist_util.git/commitdiff
wip #4978 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 23 Dec 2021 13:10:50 +0000 (14:10 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 23 Dec 2021 13:10:50 +0000 (14:10 +0100)
src/Files/DirectorySortedIterator.php [new file with mode: 0644]

diff --git a/src/Files/DirectorySortedIterator.php b/src/Files/DirectorySortedIterator.php
new file mode 100644 (file)
index 0000000..4d56c5c
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+namespace Cubist\Util\Files;
+
+use Iterator;
+use SplHeap;
+
+class DirectorySortedIterator extends SplHeap
+{
+    public function __construct(Iterator $iterator)
+    {
+        foreach ($iterator as $item) {
+            $this->insert($item);
+        }
+    }
+    public function compare($b,$a)
+    {
+        return strcmp($a->getRealpath(), $b->getRealpath());
+    }
+}