Edit report at http://bugs.php.net/bug.php?id=41758&edit=1

 ID:               41758
 Updated by:       [email protected]
 Reported by:      hedvall at gmail dot com
 Summary:          SORT_LOCALE_STRING broken for sort() in PHP6
-Status:           Assigned
+Status:           Wont fix
 Type:             Bug
 Package:          Arrays related
 Operating System: Win2k SP4
 PHP Version:      6CVS-2007-06-21 (snap)
 Assigned To:      andrei



Previous Comments:
------------------------------------------------------------------------
[2007-06-21 10:19:30] hedvall at gmail dot com

Description:
------------
According to the documentation for sort(), you must use
i18n_loc_set_default() for sort() with SORT_LOCALE_STRING to work in
PHP6. However, i18n_loc_set_default() is an undefined function. The
documentation instead refers to locale_set_default(). When setting the
locale to "sv_SE" (correct) the function returns false, but when setting
it to "sv_PHP" (incorrect) the function returns true which is the wrong
behavior. The example from locale_set_default() uses "pt_PT" which can
be set, but when sorting the result turns out the wrong way. When using
locale_get_default() it returns what was set with locale_set_default()
even if that function turned it down by returning false.

When later using sort() or asort() (or any other sort) with
SORT_LOCALE_STRING the result is the same as a normal sort.

Reproduce code:
---------------
<?php

//Code from the documentation for locale_set_default()



// the list of the strings to sort

$array = array(

    'caramelo',

    'cacto',

    'caçada'

);



// set our locale (Portuguese, in this case)

locale_set_default('pt_PT');



// sort using the locale we previously set

sort($array, SORT_LOCALE_STRING);



print_r($array);

?>

Expected result:
----------------
Array

(

    [0] => caçada

    [1] => cacto

    [2] => caramelo

)

Actual result:
--------------
Array

(

    [0] => cacto

    [1] => caramelo

    [2] => caçada

)


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=41758&edit=1

Reply via email to