title: PHP RecursiveDirectoryIterator Self_first isnt working
body: <p>Im trying to traverse a file tree in a self first order, so I would expect the files in a directory to be all listed first before going down to the next level. However for some reason this is not happening. Please find below my code</p>
  
  <pre><code>$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($f["path"],   RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
  
  foreach ($it as $fileObject) {
      echo $fileObject."\n";
  }
  </code></pre>
  
  <p>And this prints the following example (if my input directory is /data/documents/</p>
  
  <ul>
  <li>/data/documents/file name 1.pdf</li>
  <li>/data/documents/filename 2.pdf</li>
  <li>/data/documents/dir A/file 4.jpg</li>
  <li>/data/documents/dir A</li>
  <li>/data/documents/file name 5.pdf</li>
  <li>/data/documents/dirB/filex.pdf</li>
  <li>/data/documents/dirB/filey.jpg</li>
  <li>/data/documents/dirB/dirC/filew.pdf</li>
  <li>/data/documents/dirB/dirC/filev.pdf</li>
  <li>/data/documents/dirB/dirC</li>
  <li>/data/documents/dirB</li>
  <li>/data/documents/file name r.pdf</li>
  </ul>
  
  <p>Yes, the files and sometimes the directories have spaces in their naming. I'm running this on the command line, using php version 
  PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57)</p>
  
  <p>Any help would be greatly appreciated. </p>
  
  <p>UPDATE:
  I would expect the following output instead;</p>
  
  <ul>
  <li>/data/documents/dir A</li>
  <li>/data/documents/dir A/file 4.jpg</li>
  <li>/data/documents/dirB</li>
  <li>/data/documents/dirB/filex.pdf</li>
  <li>/data/documents/dirB/filey.jpg</li>
  <li>/data/documents/dirB/dirC</li>
  <li>/data/documents/dirB/dirC/filew.pdf</li>
  <li>/data/documents/dirB/dirC/filev.pdf</li>
  <li>/data/documents/file name 1.pdf</li>
  <li>/data/documents/filename 2.pdf</li>
  <li>/data/documents/file name 5.pdf</li>
  <li>/data/documents/file name r.pdf</li>
  </ul>