Sokil\Mongo\Operator::pushEachSort PHP Method

pushEachSort() public method

The $sort modifier orders the elements of an array during a $push operation.
public pushEachSort ( string $field, array $sort ) : Operator
$field string
$sort array
return Operator
    public function pushEachSort($field, array $sort)
    {
        // add modifiers
        if (!$sort) {
            throw new Exception('Sort condition is empty');
        }
        if (!isset($this->operators['$push'][$field]['$each'])) {
            throw new Exception('Field ' . $field . ' must be pushed with $each modifier');
        }
        $this->operators['$push'][$field]['$sort'] = $sort;
        return $this;
    }