Php Mongodb聚合片

Php Mongodb聚合片,php,mongodb,nosql,Php,Mongodb,Nosql,所以我有一个数据集合,每个文档都有一系列注释,我需要进行分页和排序。我尝试了类似的方法,但没有成功: $comments = $this->aggregate(array( array('$match' => array('_id' => new \MongoId($id))), array('$match' => array('comments' => array('$slice' => array($skip,$li

所以我有一个数据集合,每个文档都有一系列注释,我需要进行分页和排序。我尝试了类似的方法,但没有成功:

    $comments = $this->aggregate(array(
        array('$match' => array('_id' => new \MongoId($id))),
        array('$match' => array('comments' => array('$slice' => array($skip,$limit))))
    ));

我不知道这如何帮助我对集合中的数组进行排序,我可以从集合中得到它,但我也想对数组进行排序。您能提供示例文档吗?Post(标题、日期、注释[0:{title:foo,'text':foo},1:{title:foo,'text':foo},2:{title:foo,'text':foo})只是一个集合,每个记录都有一个注释数组,我还需要对数组进行如下排序:2,1,0