roundcubemail/program/lib/Roundcube/rcube_imap.php
public function sort_folder_list($a_folders, $skip_default = false)
    {
        $specials  = array_merge(array('INBOX'), array_values($this->get_special_folders()));
        $folders   = array();

        // convert names to UTF-8
        foreach ($a_folders as $folder) {
            // for better performance skip encoding conversion
            // if the string does not look like UTF7-IMAP
            $folders[$folder] = strpos($folder, '&') === false ? $folder : rcube_charset::convert($folder, 'UTF7-IMAP');
        }

        // sort folders
        // asort($folders, SORT_LOCALE_STRING) is not properly sorting case sensitive names
        uasort($folders, array($this, 'sort_folder_comparator'));

        $folders = array_keys($folders);

        if ($skip_default) {
            return $folders;
        }

        // force the type of folder name variable (#1485527)
        $folders  = array_map('strval', $folders);
        $out      = array();

        // finally we must put special folders on top and rebuild the list
        // to move their subfolders where they belong...
        $specials = array_unique(array_intersect($specials, $folders));
        $folders  = array_merge($specials, array_diff($folders, $specials));

        $this->sort_folder_specials(null, $folders, $specials, $out);

        return $out;
    }
public function sort_folder_list($a_folders, $skip_default = false)
    {
        $specials  = array_merge(array('INBOX'), array_values($this->get_special_folders()));
        $folders   = array();

        // convert names to UTF-8
        foreach ($a_folders as $folder) {
            // for better performance skip encoding conversion
            // if the string does not look like UTF7-IMAP
            $folders[$folder] = strpos($folder, '&') === false ? $folder : rcube_charset::convert($folder, 'UTF7-IMAP');
        }

        // sort folders
        // asort($folders, SORT_LOCALE_STRING) is not properly sorting case sensitive names
        uasort($folders, array($this, 'sort_folder_comparator'));

        $folders = array_keys($folders);

        if ($skip_default) {
            return $folders;
        }

        // force the type of folder name variable (#1485527)
        $folders  = array_map('strval', $folders);
        $out      = array();

        // finally we must put special folders on top and rebuild the list
        // to move their subfolders where they belong...
        $specials = array_unique(array_intersect($specials, $folders));
        $folders  = array_merge($specials, array_diff($folders, $specials));

        $this->sort_folder_specials(null, $folders, $specials, $out);

        return $out;
    }
public function sort_folder_list ( $ a_folders , $ skip_default = false ) { $ specials = array_merge ( array ( 'INBOX' ) , array_values ( $ this -> get_special_folders ( ) ) ) ; $ folders = array ( ) ; // convert names to UTF-8 foreach ( $ a_folders as $ folder ) { // for better performance skip encoding conversion // if the string does not look like UTF7-IMAP $ folders [ $ folder ] = strpos ( $ folder , '&' ) === false ? $ folder : rcube_charset :: convert ( $ folder , 'UTF7-IMAP' ) ; } // sort folders // asort($folders, SORT_LOCALE_STRING) is not properly sorting case sensitive names uasort ( $ folders , array ( $ this , 'sort_folder_comparator' ) ) ; $ folders = array_keys ( $ folders ) ; if ( $ skip_default ) { return $ folders ; } // force the type of folder name variable (#1485527) $ folders = array_map ( 'strval' , $ folders ) ; $ out = array ( ) ; // finally we must put special folders on top and rebuild the list // to move their subfolders where they belong... $ specials = array_unique ( array_intersect ( $ specials , $ folders ) ) ; $ folders = array_merge ( $ specials , array_diff ( $ folders , $ specials ) ) ; $ this -> sort_folder_specials ( null , $ folders , $ specials , $ out ) ; return $ out ; }
Sort folders first by default folders and then in alphabethical order

@param array $a_folders    Folders list
@param bool  $skip_default Skip default folders handling

@return array Sorted list
Sort folders first by default folders and then in alphabethical order