ID: 9671
Updated by: sniper
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Closed
Bug Type: Arrays related
Assigned To: 
Comments:

The sort() function isn't locale aware. Use this instead:

<?

// List of norwegian names, with norwegian letters
$to_be_sorted = array(mamma, øyvind, sondre, værner, ærlend, odd, hedvig, åsmund, 
birgit);

setlocale("LC_COLLATE", "no_NO");
usort($to_be_sorted, "strcoll");

print_r($to_be_sorted);

?>

http://www.php.net/strcoll
http://www.php.net/setlocale

--Jani


Previous Comments:
---------------------------------------------------------------------------

[2001-03-10 07:51:05] [EMAIL PROTECTED]
I think I have found a bug in the function 'sort'. It does not sort correct with 
norwegian letters. The norwegian alphabeth is made of 29 letters. The three last ones 
are spesial for norway (and sweden and denmark). 

Heres a sample of our alphabeth:
abcdefghijklmnopqrstuvwxyzæøå

And here are some code...

<?

// List of norwegian names, with norwegian letters
$to_be_sorted = array(mamma, øyvind, sondre, værner, ærlend, odd, hedvig, åsmund, 
birgit);

sort($to_be_sorted);

for ($i = 0; $i < sizeof($to_be_sorted); $i ++) {
  echo $to_be_sorted[$i]."<br>n";
}

?>

This prodused this putput:

birgit 
hedvig 
mamma  
odd 
sondre 
værner 
åsmund 
ærlend 
øyvind 

But it should have been:

birgit
hedvig
mamma 
odd 
sondre 
værner 
ærlend 
øyvind 
åsmund 

Yours Håkon Flatøy

PS: PHP is GREAT!

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



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9671&edit=2


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to