我有一个像:
这样的数组array(3) {
[0] => object(stdClass)#322 (2) {
["date"]=> string(10) "07-01-2015"
["details"]=> string(191) "Major Event Major Event Major Event Major Event Major Event Major Event Major Event Major Event Major Event Major Event Major Event Major Event Major Event Major Event Major Event Major Event"
}
[1]=> object(stdClass)#323 (2) {
["date"]=> string(10) "06-01-2015"
["details"]=> string(11) "Major Event"
}
[2]=> object(stdClass)#324 (2) {
["date"]=> string(10) "14-01-2015"
["details"]=> string(11) "Major Event"
}
}
我想对此进行排序。那怎么可能呢?
答案 0 :(得分:0)
这看起来像是php中var_dump数组的输出所以我假设这是在php中你应该使用usort和自定义比较函数
function date_compare($a, $b)
{
$t1 = strtotime($a->date);
$t2 = strtotime($b->date);
return $t1 - $t2;
}
usort($array, 'date_compare');