original_string: public function sort(
          $table,
          $column,
          $order,
          $trashed = false,
          DatabaseManager $db
      ) {
          $db = $db->connection();
          $data = $db->table($table);
  
          // Check for trashed data
          $data = $trashed ? $data->whereNotNull('deleted_at') : $data->whereNull('deleted_at');
  
          if ($table == 'users') {
              $data = $data->join('roles', 'users.role_id', '=', 'roles.id');
          }
  
          if ($table == 'posts') {
              $data = $data->join('statuses', 'posts.status_id', '=', 'statuses.id');
          }
  
          $data = $data
              ->orderBy($column, $order)
              ->paginate($this->config->items_per_page);
  
          return $data;
      }
code: public function sort(
          $table,
          $column,
          $order,
          $trashed = false,
          DatabaseManager $db
      ) {
          $db = $db->connection();
          $data = $db->table($table);
  
          // Check for trashed data
          $data = $trashed ? $data->whereNotNull('deleted_at') : $data->whereNull('deleted_at');
  
          if ($table == 'users') {
              $data = $data->join('roles', 'users.role_id', '=', 'roles.id');
          }
  
          if ($table == 'posts') {
              $data = $data->join('statuses', 'posts.status_id', '=', 'statuses.id');
          }
  
          $data = $data
              ->orderBy($column, $order)
              ->paginate($this->config->items_per_page);
  
          return $data;
      }
code_tokens: public function sort ( $ table , $ column , $ order , $ trashed = false , DatabaseManager $ db ) { $ db = $ db -> connection ( ) ; $ data = $ db -> table ( $ table ) ; // Check for trashed data $ data = $ trashed ? $ data -> whereNotNull ( 'deleted_at' ) : $ data -> whereNull ( 'deleted_at' ) ; if ( $ table == 'users' ) { $ data = $ data -> join ( 'roles' , 'users.role_id' , '=' , 'roles.id' ) ; } if ( $ table == 'posts' ) { $ data = $ data -> join ( 'statuses' , 'posts.status_id' , '=' , 'statuses.id' ) ; } $ data = $ data -> orderBy ( $ column , $ order ) -> paginate ( $ this -> config -> items_per_page ) ; return $ data ; }
docstring: Order the data of a given table on the given column
  and the given order
  
  @param string $table
  @param string $column
  @param string $order
  @param bool $trashed
  @param \Illuminate\Database\DatabaseManager $db
  @return object
docstring_tokens: Order the data of a given table on the given column and the given order