私の脳が機能しているだけかもしれませんが、アイスランドのアルファベットに従ってこの配列をソートする方法がわかりません。これを正しく行うためのクリーンな方法が必要ですか?( name の値でソートしたい ) 参考までに、これはアイスランドのアルファベット aábdðeéfghiíjklmnoóprstuúvxyýþæö です。
$isAlphabet = 'aábdðeéfghiíjklmnoóprstuúvxyýþæö';
$myGang = array();
$asdf22 = new stdClass();
$asdf22->name = 'Þröstur';
$asdf22->email = 'who@cares.is';
$asdf202 = new stdClass();
$asdf202->name = 'Árni';
$asdf202->email = 'who@cares.is';
$asdf52 = new stdClass();
$asdf52->name = 'Arnar';
$asdf52->email = 'who@cares.is';
$asdf55 = new stdClass();
$asdf55->name = 'Óskar';
$asdf55->email = 'who@cares.is';
$asdf33 = new stdClass();
$asdf33->name = 'Aðalheiður';
$asdf33->email = 'who@cares.is';
$asdf13 = new stdClass();
$asdf13->name = 'Baldur';
$asdf13->email = 'who@cares.is';
$myGang[22] = $asdf22;
$myGang[202] = $asdf202;
$myGang[55] = $asdf55;
$myGang[52] = $asdf52;
$myGang[33] = $asdf33;
$myGang[13] = $asdf13;
sort($myGang); // I know this is not the right way..
print_r($myGang);
/* 正しい順序: Arnar Aðalheiður Árni Baldur Óskar Þröstur
しかし、これは出力です:
Array
(
[0] => stdClass Object
(
[name] => Arnar
[email] => who@cares.is
)
[1] => stdClass Object
(
[name] => Aðalheiður
[email] => who@cares.is
)
[2] => stdClass Object
(
[name] => Baldur
[email] => who@cares.is
)
[3] => stdClass Object
(
[name] => Árni
[email] => who@cares.is
)
[4] => stdClass Object
(
[name] => Óskar
[email] => who@cares.is
)
[5] => stdClass Object
(
[name] => Þröstur
[email] => who@cares.is
)
)