也许我的大脑正在工作,但我不知道如何根据冰岛字母表对这个数组进行排序。必须有一种干净的方式来做到这一点吗?(我想按名称的值对其进行排序)仅供参考,这是冰岛字母 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
)
)