Doctrine\MongoDB\Aggregation\Builder::sort PHP Method

sort() public method

If sorting by multiple fields, the first argument should be an array of field name (key) and order (value) pairs.
See also: http://docs.mongodb.org/manual/reference/operator/aggregation/sort/
public sort ( array | string $fieldName, integer | string $order = null ) : Doctrine\MongoDB\Aggregation\Stage\Sort
$fieldName array | string Field name or array of field/order pairs
$order integer | string Field order (if one field is specified)
return Doctrine\MongoDB\Aggregation\Stage\Sort
    public function sort($fieldName, $order = null)
    {
        return $this->addStage(new Stage\Sort($this, $fieldName, $order));
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function sort($fieldName, $order = null)
 {
     $fields = is_array($fieldName) ? $fieldName : [$fieldName => $order];
     return parent::sort($this->getDocumentPersister()->prepareSortOrProjection($fields));
 }
All Usage Examples Of Doctrine\MongoDB\Aggregation\Builder::sort