/**
  * Sets the sort definition for this data provider.
  * @param array|Sort|boolean $value the sort definition to be used by this data provider.
  * This can be one of the following:
  *
  * - a configuration array for creating the sort definition object. The "class" element defaults
  *   to 'rock\data\Sort'
  * - an instance of {@see \rock\data\Sort} or its subclass
  * - false, if sorting needs to be disabled.
  *
  * @throws DataProviderException
  */
 public function setSort($value)
 {
     if (is_array($value)) {
         $config = ['class' => Sort::className()];
         $this->_sort = Instance::ensure(array_merge($config, $value));
     } elseif ($value instanceof Sort || $value === false) {
         $this->_sort = $value;
     } else {
         throw new DataProviderException('Only Sort instance, configuration array or false is allowed.');
     }
 }
 /**
  * Sorts the data models according to the given sort definition
  * @param array $models the models to be sorted
  * @param Sort $sort the sort definition
  * @return array the sorted data models
  */
 protected function sortModels($models, $sort)
 {
     $orders = $sort->getOrders();
     if (!empty($orders)) {
         ArrayHelper::multisort($models, array_keys($orders), array_values($orders));
     }
     return $models;
 }