You are here: Sort order of a sorted array « All PHP « IT news, forums, messages
Sort order of a sorted array

Posted by Stefan Mueller on 12/17/05 21:43

With the PHP command 'sort' I can sort an array. However, it doesn't exactly
sort the array I'd like to:

<html>
<body>
<?php
$my_array[0] = array("AA", "11");
$my_array[1] = array("AA", "22");
$my_array[2] = array("aa", "22");
$my_array[3] = array("AB", "11");
$my_array[4] = array("ab", "11");
$my_array[5] = array("ab", "22");
$my_array[6] = array("δb", "11");
$my_array[7] = array("ab", "33");
$my_array[8] = array("bb", "11");
$my_array[9] = array("eb", "11");
$my_array[10] = array("ιb", "11");
$my_array[11] = array("fa", "11");

sort($my_array);

for ($i = 0; $i <= 11; $i++) {
echo $my_array[$i][0] . " / " . $my_array[$i][1] . "<br>";
}
?>
</body>
</html>

=========================

Result:
AA / 11
AA / 22
AB / 11
aa / 22
ab / 11
ab / 22
ab / 33
bb / 11
eb / 11
fa / 11
δb / 11
ιb / 11

Requested result:
AA / 11
AA / 22
aa / 22
AB / 11
ab / 11
δb / 11
ab / 22
ab / 33
bb / 11
eb / 11
ιb / 11
fa / 11

Is it somehow possible to tell sort that it has to handle 'A' like 'a' and
also 'δ' like 'a'?

Stefan

 

Navigation:

[Reply to this 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

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