Sorting in PHP

From: Date: Tue, 02 Aug 2005 17:51:02 +0000
Subject: Sorting in PHP
Groups: php.general 
Request: Send a blank email to php-general+get-219851@lists.php.net to get a copy of this message
Hi, i need to sort data using ksort. Its complex data out from a database (and no i can't sort it using the database sadly). I can change my code to reflect a new way of sorting but only to some extent, im limited. Now from the data i build an array of the things i need to display, using the names of the hockey players i create a list that is supposed to be sorted, look at the result, you'll see that accents are not sorted althought my var_dump(setlocale(...)) returns that the french locale (string(5) "fr_CA") has been chosen. Is there anything wrong? can i change my code to fix this problem and how, cause all my tries point to nothing. (Btw i tried all the installed locales to no avail.)
Balodis      Devon    1985-06-11    Baie-Comeau     AF     *    Joueur
Balogh      Sébastien    1987-01-17    Baie-Comeau     AF       Joueur
Blais      Alexandre    1986-06-23    Baie-Comeau     AF        Joueur
Blouin      Sébastien    1987-03-04    Baie-Comeau     MAJ      Joueur
Bossé      Simon    1900-01-01    Baie-Comeau     AF     *    Joueur
Bouchard      François    1988-04-26    Baie-Comeau     MAJ       Joueur
Boudreault      Stéphane    1986-01-16    Baie-Comeau     AF      Joueur
Boulianne      Yannick    1987-10-19    Baie-Comeau     AF       Joueur
Bradley      Adam    1985-09-18    Baie-Comeau     AF     *    Joueur
Breault      Benjamin    1988-02-21    Baie-Comeau     MAJ     Joueur
Brodeur      Benoît    1987-03-07    Baie-Comeau     AF         Joueur
Bédard      Mikaël    1987-12-13    Baie-Comeau     AF         Joueur
Bélanger      Maxime    1986-03-03    Baie-Comeau     MAJ         Joueur
Bérubé      Mathieu    1986-10-01    Baie-Comeau     AF         Joueur
(In case you didn't notice, the last 3 lines are the problem, they should be right after the 3 first lines (after the a's)) ######################################## //$teamdata gathered higher up in the code $tmp_players = list_get_players($mysql_link, $_SESSION['team_list'], $_GET['sys_date'], $_SESSION['histo_directdata']); //Sort it alpha cause its not done right now foreach($tmp_players as $player){ $players[0][$player['register_file']['info_lname'].'-'.$player['register_file']['info_fname'].'-'.$player['register_file']['info_mname'].'-'.$player['register_file']['info_datenais']] = $player; } unset($tmpplayers, $player); var_dump(setlocale(LC_ALL, array('fr_CA', 'fr_CA.iso88591', 'fr_CA.utf8'))); ksort($players[0], SORT_LOCALE_STRING);

« previous php.general (#219851) next »