public static function ksort(array &$arr, $sortflag = core_collator::SORT_STRING) {
        $keys = array_keys($arr);
        if (!self::asort($keys, $sortflag)) {
            return false;
        }
        // This is a bit slow, but we need to keep the references
        $original = $arr;
        $arr = array(); // Surprisingly this does not break references outside
        foreach ($keys as $key) {
            $arr[$key] = $original[$key];
        }

        return true;
    }
public static function ksort(array &$arr, $sortflag = core_collator::SORT_STRING) {
        $keys = array_keys($arr);
        if (!self::asort($keys, $sortflag)) {
            return false;
        }
        // This is a bit slow, but we need to keep the references
        $original = $arr;
        $arr = array(); // Surprisingly this does not break references outside
        foreach ($keys as $key) {
            $arr[$key] = $original[$key];
        }

        return true;
    }
public static function ksort ( array & $ arr , $ sortflag = core_collator :: SORT_STRING ) { $ keys = array_keys ( $ arr ) ; if ( ! self :: asort ( $ keys , $ sortflag ) ) { return false ; } // This is a bit slow, but we need to keep the references $ original = $ arr ; $ arr = array ( ) ; // Surprisingly this does not break references outside foreach ( $ keys as $ key ) { $ arr [ $ key ] = $ original [ $ key ] ; } return true ; }
Locale aware sorting, the key associations are kept, keys are sorted alphabetically.

@param array $arr array to be sorted (reference)
@param int $sortflag One of core_collator::SORT_NUMERIC, core_collator::SORT_STRING, core_collator::SORT_NATURAL, core_collator::SORT_REGULAR
optionally "|" core_collator::CASE_SENSITIVE
@return bool True on success
Locale aware sorting the key associations are kept keys are sorted alphabetically .