我有这个数组:
var query = new Parse.Query('arena');
query.each((arena) => {
var promise1 = NotificationServices.sendNotification(getPlayerOne(arena));
var promise2 = NotificationServices.sendNotification(getPlayerTwo(arena));
return Parse.Promise.when([promise1, promise2])
.then(() => Parse.Promise.as(), () => Parse.Promise.as());
})
我想将此数组排序为:
Array
(
[26] => Array
(
[total_auctions] => 1
[total_price] => 0
)
[24] => Array
(
[total_auctions] => 0
[total_price] => 0
)
[25] => Array
(
[total_auctions] => 0
[total_price] => 0
)
)
我尝试使用Array
(
[24] => Array
(
[total_auctions] => 0
[total_price] => 0
)
[25] => Array
(
[total_auctions] => 0
[total_price] => 0
)
[26] => Array
(
[total_auctions] => 1
[total_price] => 0
)
)
但不行。你能帮我吗 ? Thx提前。我不明白问题出在哪里,通常应该有效
答案 0 :(得分:-1)
只需使用ksort()对任何数组键进行排序
<?php
$arr = array(
'26' => array('total_auctions' => 1,'total_price' => 0),
'24' => array('total_auctions' => 0,'total_price' => 0),
'25' => array('total_auctions' => 0,'total_price' => 0)
);
ksort($arr);
print '<pre>';print_r($arr);
exit;
?>