original_string: public function get_sort_arrows(array $extrafields = array()) {
          global $OUTPUT, $CFG;
          $arrows = array();
  
          $strsortasc   = $this->get_lang_string('sortasc', 'grades');
          $strsortdesc  = $this->get_lang_string('sortdesc', 'grades');
          $iconasc = $OUTPUT->pix_icon('t/sort_asc', $strsortasc, '', array('class' => 'iconsmall sorticon'));
          $icondesc = $OUTPUT->pix_icon('t/sort_desc', $strsortdesc, '', array('class' => 'iconsmall sorticon'));
  
          // Sourced from tablelib.php
          // Check the full name display for sortable fields.
          if (has_capability('moodle/site:viewfullnames', $this->context)) {
              $nameformat = $CFG->alternativefullnameformat;
          } else {
              $nameformat = $CFG->fullnamedisplay;
          }
  
          if ($nameformat == 'language') {
              $nameformat = get_string('fullnamedisplay');
          }
  
          $arrows['studentname'] = '';
          $requirednames = order_in_string(get_all_user_name_fields(), $nameformat);
          if (!empty($requirednames)) {
              foreach ($requirednames as $name) {
                  $arrows['studentname'] .= html_writer::link(
                      new moodle_url($this->baseurl, array('sortitemid' => $name)), $this->get_lang_string($name)
                  );
                  if ($this->sortitemid == $name) {
                      $arrows['studentname'] .= $this->sortorder == 'ASC' ? $iconasc : $icondesc;
                  }
                  $arrows['studentname'] .= ' / ';
              }
  
              $arrows['studentname'] = substr($arrows['studentname'], 0, -3);
          }
  
          foreach ($extrafields as $field) {
              $fieldlink = html_writer::link(new moodle_url($this->baseurl,
                      array('sortitemid'=>$field)), get_user_field_name($field));
              $arrows[$field] = $fieldlink;
  
              if ($field == $this->sortitemid) {
                  if ($this->sortorder == 'ASC') {
                      $arrows[$field] .= $iconasc;
                  } else {
                      $arrows[$field] .= $icondesc;
                  }
              }
          }
  
          return $arrows;
      }
code: public function get_sort_arrows(array $extrafields = array()) {
          global $OUTPUT, $CFG;
          $arrows = array();
  
          $strsortasc   = $this->get_lang_string('sortasc', 'grades');
          $strsortdesc  = $this->get_lang_string('sortdesc', 'grades');
          $iconasc = $OUTPUT->pix_icon('t/sort_asc', $strsortasc, '', array('class' => 'iconsmall sorticon'));
          $icondesc = $OUTPUT->pix_icon('t/sort_desc', $strsortdesc, '', array('class' => 'iconsmall sorticon'));
  
          // Sourced from tablelib.php
          // Check the full name display for sortable fields.
          if (has_capability('moodle/site:viewfullnames', $this->context)) {
              $nameformat = $CFG->alternativefullnameformat;
          } else {
              $nameformat = $CFG->fullnamedisplay;
          }
  
          if ($nameformat == 'language') {
              $nameformat = get_string('fullnamedisplay');
          }
  
          $arrows['studentname'] = '';
          $requirednames = order_in_string(get_all_user_name_fields(), $nameformat);
          if (!empty($requirednames)) {
              foreach ($requirednames as $name) {
                  $arrows['studentname'] .= html_writer::link(
                      new moodle_url($this->baseurl, array('sortitemid' => $name)), $this->get_lang_string($name)
                  );
                  if ($this->sortitemid == $name) {
                      $arrows['studentname'] .= $this->sortorder == 'ASC' ? $iconasc : $icondesc;
                  }
                  $arrows['studentname'] .= ' / ';
              }
  
              $arrows['studentname'] = substr($arrows['studentname'], 0, -3);
          }
  
          foreach ($extrafields as $field) {
              $fieldlink = html_writer::link(new moodle_url($this->baseurl,
                      array('sortitemid'=>$field)), get_user_field_name($field));
              $arrows[$field] = $fieldlink;
  
              if ($field == $this->sortitemid) {
                  if ($this->sortorder == 'ASC') {
                      $arrows[$field] .= $iconasc;
                  } else {
                      $arrows[$field] .= $icondesc;
                  }
              }
          }
  
          return $arrows;
      }
code_tokens: public function get_sort_arrows ( array $ extrafields = array ( ) ) { global $ OUTPUT , $ CFG ; $ arrows = array ( ) ; $ strsortasc = $ this -> get_lang_string ( 'sortasc' , 'grades' ) ; $ strsortdesc = $ this -> get_lang_string ( 'sortdesc' , 'grades' ) ; $ iconasc = $ OUTPUT -> pix_icon ( 't/sort_asc' , $ strsortasc , '' , array ( 'class' => 'iconsmall sorticon' ) ) ; $ icondesc = $ OUTPUT -> pix_icon ( 't/sort_desc' , $ strsortdesc , '' , array ( 'class' => 'iconsmall sorticon' ) ) ; // Sourced from tablelib.php // Check the full name display for sortable fields. if ( has_capability ( 'moodle/site:viewfullnames' , $ this -> context ) ) { $ nameformat = $ CFG -> alternativefullnameformat ; } else { $ nameformat = $ CFG -> fullnamedisplay ; } if ( $ nameformat == 'language' ) { $ nameformat = get_string ( 'fullnamedisplay' ) ; } $ arrows [ 'studentname' ] = '' ; $ requirednames = order_in_string ( get_all_user_name_fields ( ) , $ nameformat ) ; if ( ! empty ( $ requirednames ) ) { foreach ( $ requirednames as $ name ) { $ arrows [ 'studentname' ] .= html_writer :: link ( new moodle_url ( $ this -> baseurl , array ( 'sortitemid' => $ name ) ) , $ this -> get_lang_string ( $ name ) ) ; if ( $ this -> sortitemid == $ name ) { $ arrows [ 'studentname' ] .= $ this -> sortorder == 'ASC' ? $ iconasc : $ icondesc ; } $ arrows [ 'studentname' ] .= ' / ' ; } $ arrows [ 'studentname' ] = substr ( $ arrows [ 'studentname' ] , 0 , - 3 ) ; } foreach ( $ extrafields as $ field ) { $ fieldlink = html_writer :: link ( new moodle_url ( $ this -> baseurl , array ( 'sortitemid' => $ field ) ) , get_user_field_name ( $ field ) ) ; $ arrows [ $ field ] = $ fieldlink ; if ( $ field == $ this -> sortitemid ) { if ( $ this -> sortorder == 'ASC' ) { $ arrows [ $ field ] .= $ iconasc ; } else { $ arrows [ $ field ] .= $ icondesc ; } } } return $ arrows ; }
docstring: Refactored function for generating HTML of sorting links with matching arrows.
  Returns an array with 'studentname' and 'idnumber' as keys, with HTML ready
  to inject into a table header cell.
  @param array $extrafields Array of extra fields being displayed, such as
  user idnumber
  @return array An associative array of HTML sorting links+arrows
docstring_tokens: Refactored function for generating HTML of sorting links with matching arrows . Returns an array with studentname and idnumber as keys with HTML ready to inject into a table header cell .