我想根据密钥(这是一个日期)对我的数组进行排序 - 最好是ASC和DESC。
我曾试图在SO上使用其中的几种方法,但一直得到不好的结果 - 所以我想我会再问这个问题。
我有这个数组:
Array
(
[2015-05-29] => Array
(
[a] => 13
[b] => 1
[c] => 12
)
[2015-05-28] => Array
(
[a] => 10
[b] => 1
[c] => 1
)
[2015-05-27] => Array
(
[a] => 2
)
[2015-05-30] => Array
(
[b] => 24
[c] => 25
)
)
我使用这个功能 - 应该根据几个帖子工作:
uasort($days, function($a, $b) {
return $a['points'] - $b['points'];
});
但它不会,因为数组会像这样返回:
Array
(
[2015-05-30] => Array
(
[b] => 24
[c] => 25
)
[2015-05-27] => Array
(
[a] => 2
)
[2015-05-28] => Array
(
[a] => 10
[b] => 1
[c] => 1
)
[2015-05-29] => Array
(
[a] => 13
[b] => 1
[c] => 12
)
)
我希望像这样返回数组:
Array
(
[2015-05-27] => Array
(
[a] => 2
)
[2015-05-28] => Array
(
[a] => 10
[b] => 1
[c] => 1
)
[2015-05-29] => Array
(
[a] => 13
[b] => 1
[c] => 12
)
[2015-05-30] => Array
(
[b] => 24
[c] => 25
)
)
或反向排列!
谁能帮我解决这个问题?