sortFilesDescByPathLength() public static method

Sort all given paths/filenames by its path length. Long path names will be listed first. This method can be useful if you have for instance a bunch of files/directories to delete. By sorting them by lengh you can make sure to delete all files within the folders before deleting the actual folder.
public static sortFilesDescByPathLength ( string[] $files ) : string[]
$files string[]
return string[]
Example #1
0
 public function test_sortFilesDescByPathLength_shouldOrderDesc_IfDifferentLengthsGiven()
 {
     $input = array('xyz/1.gif', '1.gif', 'x', 'x/xyz.gif', 'xyz', 'xxyyzzgg', 'xyz/long.gif');
     $result = Filesystem::sortFilesDescByPathLength($input);
     $expected = array('xyz/long.gif', 'x/xyz.gif', 'xyz/1.gif', 'xxyyzzgg', '1.gif', 'xyz', 'x');
     $this->assertEquals($expected, $result);
 }