Reply to Re: Sort order of a sorted array

Your name:

Reply:


Posted by Janwillem Borleffs on 12/18/05 03:10

Stefan Mueller wrote:
> Is it somehow possible to tell sort that it has to handle 'A' like
> 'a' and also 'δ' like 'a'?
>

Not with sort; have a go with array_multisort instead:

// Translates 'δ' to 'a', 'λ' to 'e' etcetera
function translate($str) {
$table = get_html_translation_table(HTML_ENTITIES);
$pattern = '/^&(.)(tilde|grave|acute|circ|tilde|uml);$/';
$ret = '';

for ($i = 0, $max = strlen($str); $i < $max; $i++) {
if (preg_match($pattern, @$table[$str{$i}], $m)) {
$ret .= $m[1];
} else {
$ret .= $str{$i};
}
}
return $ret;
}

$values = array();
foreach ($my_array as $e) {
$values[] = translate(strtolower($e[0])) . $e[1];
}
array_multisort($values, SORT_ASC, $my_array);


JW

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация