code: public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
      {
          $orders = $this->_config['orders'];
  
          $args = [$query, $options, $primary];
  
          foreach ($orders as $config) {
              if ((!empty($config['callback'])
                      && call_user_func_array($config['callback'], $args)
                  ) || !$query->clause('order')
              ) {
                  $query->order($config['order']);
                  break;
              }
          }
      }
docs: Add default order clause to query as necessary.
  
  @param \Cake\Event\Event $event Event
  @param \Cake\ORM\Query $query Query
  @param \ArrayObject $options Options
  @param bool $primary Boolean indicating whether it's primary query.
  @return void