original_string: public function orderBy(string $key, string $direction)
      {
          if (str_contains($key, '.')) {
              $fullPath          = explode('.', $key);
              $relationPath      = implode('.', array_slice($fullPath, 0, -1));
              $relationKey       = last($fullPath);
              $result            = array_get($this->relations, $relationPath, ['filters' => [], 'sorts' => []]);
              $result['sorts'][] = new OrderBy($relationKey, $direction);
              array_set($this->relations, $relationPath, $result);
          } else {
              $this->sorts[] = new OrderBy($key, $direction);
          }
          return $this;
      }
code: public function orderBy(string $key, string $direction)
      {
          if (str_contains($key, '.')) {
              $fullPath          = explode('.', $key);
              $relationPath      = implode('.', array_slice($fullPath, 0, -1));
              $relationKey       = last($fullPath);
              $result            = array_get($this->relations, $relationPath, ['filters' => [], 'sorts' => []]);
              $result['sorts'][] = new OrderBy($relationKey, $direction);
              array_set($this->relations, $relationPath, $result);
          } else {
              $this->sorts[] = new OrderBy($key, $direction);
          }
          return $this;
      }
code_tokens: public function orderBy ( string $ key , string $ direction ) { if ( str_contains ( $ key , '.' ) ) { $ fullPath = explode ( '.' , $ key ) ; $ relationPath = implode ( '.' , array_slice ( $ fullPath , 0 , - 1 ) ) ; $ relationKey = last ( $ fullPath ) ; $ result = array_get ( $ this -> relations , $ relationPath , [ 'filters' => [ ] , 'sorts' => [ ] ] ) ; $ result [ 'sorts' ] [ ] = new OrderBy ( $ relationKey , $ direction ) ; array_set ( $ this -> relations , $ relationPath , $ result ) ; } else { $ this -> sorts [ ] = new OrderBy ( $ key , $ direction ) ; } return $ this ; }
docstring: It adds order by
  
  @param string $key       Column name
  @param string $direction Direction
  
  @return $this
docstring_tokens: It adds order by