original_string: public function get_external_files($repositoryid, $sort = '') {
          global $DB;
          $sql = "SELECT ".self::instance_sql_fields('f', 'r')."
                    FROM {files} f
               LEFT JOIN {files_reference} r
                         ON f.referencefileid = r.id
                   WHERE r.repositoryid = ?";
          if (!empty($sort)) {
              $sql .= " ORDER BY {$sort}";
          }
  
          $result = array();
          $filerecords = $DB->get_records_sql($sql, array($repositoryid));
          foreach ($filerecords as $filerecord) {
              $result[$filerecord->pathnamehash] = $this->get_file_instance($filerecord);
          }
          return $result;
      }
code: public function get_external_files($repositoryid, $sort = '') {
          global $DB;
          $sql = "SELECT ".self::instance_sql_fields('f', 'r')."
                    FROM {files} f
               LEFT JOIN {files_reference} r
                         ON f.referencefileid = r.id
                   WHERE r.repositoryid = ?";
          if (!empty($sort)) {
              $sql .= " ORDER BY {$sort}";
          }
  
          $result = array();
          $filerecords = $DB->get_records_sql($sql, array($repositoryid));
          foreach ($filerecords as $filerecord) {
              $result[$filerecord->pathnamehash] = $this->get_file_instance($filerecord);
          }
          return $result;
      }
code_tokens: public function get_external_files ( $ repositoryid , $ sort = '' ) { global $ DB ; $ sql = "SELECT " . self :: instance_sql_fields ( 'f' , 'r' ) . "
                    FROM {files} f
               LEFT JOIN {files_reference} r
                         ON f.referencefileid = r.id
                   WHERE r.repositoryid = ?" ; if ( ! empty ( $ sort ) ) { $ sql .= " ORDER BY {$sort}" ; } $ result = array ( ) ; $ filerecords = $ DB -> get_records_sql ( $ sql , array ( $ repositoryid ) ) ; foreach ( $ filerecords as $ filerecord ) { $ result [ $ filerecord -> pathnamehash ] = $ this -> get_file_instance ( $ filerecord ) ; } return $ result ; }
docstring: Returns all files belonging to given repository
  
  @param int $repositoryid
  @param string $sort A fragment of SQL to use for sorting
docstring_tokens: Returns all files belonging to given repository