@param string $dir
@param int    $sorting_order

@return array
353334
public function scandir($dir, $sorting_order = SCANDIR_SORT_ASCENDING)
    {
        $r = @scandir($this->alias->resolve($dir), $sorting_order);
        if ($r === false) {
            throw new RuntimeException(['scandir `:dir` directory failed: :last_error_message', 'dir' => $dir]);
        }

        $items = [];
        foreach ($r as $item) {
            if ($item !== '.' && $item !== '..') {
                $items[] = $item;
            }
        }

        return $items;
    }
667404
function orderBy($column, $dir = null) {
		if (null !== $dir && '' !== $dir) {
			$dir = strtoupper($dir);
			if ($dir !== self::ASC && $dir !== self::DESC) {
				throw new RuntimeException("$dir is not a valid sorting direction.");
			}
			$column .= ' ' . $dir;
		}
		$this->orders[] = trim($column);
		return $this;
	}
243724
protected function getSortDirections($order)
	{
		$segs=explode(',',$order);
		$directions=array();
		foreach($segs as $seg)
		{
			if(preg_match('/(.*?)(\s+(desc|asc))?$/i',trim($seg),$matches))
				$directions[$matches[1]]=isset($matches[3]) && !strcasecmp($matches[3],'desc');
			else
				$directions[trim($seg)]=false;
		}
		return $directions;
	}
224102
protected static function readdir($dir)
    {
        $entries = array();
        foreach (scandir($dir) as $entry) {
            if(($entry != '.') && ($entry != '..')){
                $current = "$dir/$entry";
                if($current != $dir){
                    if(is_dir($current)){
                        $aux = self::readdir($current);
                        $entries = array_merge($entries, $aux);
                    }else{
                        if(preg_match("/\w*?Controller.php/", $entry)){
                            $entries[] = $current;
                        }
                    }
                }
            }
        }

        return $entries;
    }
589067
public static File[] listFilesSortedByModDate(File dir) {
        File[] backupDirFiles = dir.listFiles();
        Arrays.sort(backupDirFiles, new FileComparator());
        return backupDirFiles;
    }
54039
public function toList( $dir = NULL )
	{
		$array	= array();
		if( !$dir || $dir == "lwr" )
		{
			if( $this->left )
				$array = array_merge( $array, $this->left->toList( $dir ) );
			$array = array_merge( $array, array( $this->value ) );
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
		}
		else if( $dir == "rwl" )
		{
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
			$array = array_merge( $array, array ($this->value));
			if( $this->left)
				$array = array_merge( $array, $this->left->toList( $dir ) );
		}
		else if( $dir == "wlr" )
		{
			$array = array_merge( $array, array ($this->value));
			if( $this->left )
				$array = array_merge( $array, $this->left->toList( $dir ) );
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
		}
		else if( $dir == "wrl" )
		{
			$array = array_merge( $array, array ($this->value));
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
			if( $this->left )
				$array = array_merge( $array, $this->left->toList( $dir ) );
		}
		return $array;
	}
17999
static public function getFolders( $dir, $recursive = false )
    {
        $subDirs = [];
        if ( ( $dh = opendir( $dir ) ) ) {
            while ( ( $file = readdir( $dh ) ) !== false ) {
                if ( $file !== '.' && $file !== '..' && is_dir( $dir . '/' . $file ) ) {
                    $subDirs[] = $file;
                    if ( $recursive ) {
                        $subDirs = array_merge( $subDirs, self::getFolders( $dir . DS . $file, true ) );
                    }
                }
            }
            closedir( $dh );
        }
        return $subDirs;
    }
341822
private function mkdir_p( $dir )
    {
        // create parent directories
        $dirElements = explode( '/', $dir );
        if ( count( $dirElements ) == 0 )
            return true;

        $result = true;
        $currentDir = $dirElements[0];

        if ( $currentDir != '' && !file_exists( $currentDir ) && !eZDir::mkdir( $currentDir, false ) )
            return false;

        for ( $i = 1; $i < count( $dirElements ); ++$i )
        {
            $dirElement = $dirElements[$i];
            if ( strlen( $dirElement ) == 0 )
                continue;

            $currentDir .= '/' . $dirElement;

            if ( !file_exists( $currentDir ) && !eZDir::mkdir( $currentDir, false ) )
                return false;

            $result = true;
        }

        return $result;
    }
1227595
protected function scanDir($dir)
    {
        $fileinfos = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
        $files     = [];
        foreach ($fileinfos as $pathname => $fileinfo) {
            if (!$fileinfo->isFile()) {
                continue;
            }

            $files[] = $pathname;
        }

        return $this->scanArray($files);
    }
993002
public static function sortBy($collection = null, $iterator = null, $sort_flag = null)
    {
        $results = array();
        foreach ($collection as $k => $item) {
            if (is_callable($iterator)) {
                $results[$k] = $iterator($item);
            }
            if (is_object($item)) {
                $results[$k] = $item->$iterator;
            } elseif (is_array($item)) {
                $results[$k] = $item[$iterator];
            }
        }
        $sort_flag = (is_null($sort_flag)) ? SORT_REGULAR : $sort_flag;
        asort($results, $sort_flag);
        foreach ($results as $k => $v) {
            $results[$k] = $collection[$k];
        }
        return $results;
    }
485294
private function getSortingColumns($sortingDefinition)
    {
        if (null === $sortingDefinition) {
            return [];
        }

        $sortingColumns = [];
        /** @var GroupAndSortingDefinitionInterface $sortingDefinition */
        foreach ($sortingDefinition as $information) {
            /** @var GroupAndSortingInformationInterface $information */
            if ($information->getProperty()) {
                $sortingColumns[] = $information->getProperty();
            }
        }

        return $sortingColumns;
    }
191078
public function sortByViewMode($viewMode, $dir = SORT_ASC)
    {
        $items = [];
        $sorted = $this->sortBy(function ($field) use ($viewMode) {
            if (isset($field->metadata->view_modes[$viewMode])) {
                return $field->metadata->view_modes[$viewMode]['ordering'];
            }

            return 0;
        }, $dir);

        foreach ($sorted as $item) {
            $items[] = $item;
        }

        return new FieldCollection($items);
    }
999526
private function getSortOrder()
    {
        return [
            $this->translator->trans(/** @Desc("Ascending") */ 'content_type.sort_field.ascending', [], 'content_type') => Location::SORT_ORDER_ASC,
            $this->translator->trans(/** @Desc("Descending") */ 'content_type.sort_field.descending', [], 'content_type') => Location::SORT_ORDER_DESC,
        ];
    }
643311
protected function getFilesFromDir($dir)
    {
        $finder = new Finder();
        $finder->files()->ignoreUnreadableDirs()->in(realpath($dir));

        foreach ($this->excludes as $exclude) {
            $finder->notPath($exclude);
        }

        foreach ($this->extensions as $extension) {
            $finder->name('*.'.$extension);
        }

        return iterator_to_array($finder);
    }
523005
protected function getMessages($dir)
    {
        $file = sprintf("%smessages/%s.php", $dir, $this->lang);
        if (file_exists($file)) {
            return include $file;
        }

        return [];
    }
1086327
protected function querySort($query, $sort = [])
    {
        $sort = $sort ?: $this->sort;

        foreach ($sort as $attribute => $order) {
            $query->orderBy($attribute, $order);
        }

        return $query;
    }
1368204
public function sortCollection(Collection $collection, $orderBy, $orderDir = 'asc', $orderManual = null, $sort_flags = null)
    {
        $items = $collection->toArray();
        if (!$items) {
            return [];
        }

        $lookup = md5(json_encode($items) . json_encode($orderManual) . $orderBy . $orderDir);
        if (!isset($this->sort[$lookup][$orderBy])) {
            $this->buildSort($lookup, $items, $orderBy, $orderManual, $sort_flags);
        }

        $sort = $this->sort[$lookup][$orderBy];

        if ($orderDir !== 'asc') {
            $sort = array_reverse($sort);
        }

        return $sort;

    }