original_string: public function new_sort_url($sort, $newsortreverse) {
          if ($newsortreverse) {
              $order = -1;
          } else {
              $order = 1;
          }
          // Tricky code to add the new sort at the start, removing it from where it was before, if it was present.
          $newsort = array_reverse($this->sort);
          if (isset($newsort[$sort])) {
              unset($newsort[$sort]);
          }
          $newsort[$sort] = $order;
          $newsort = array_reverse($newsort);
          if (count($newsort) > self::MAX_SORTS) {
              $newsort = array_slice($newsort, 0, self::MAX_SORTS, true);
          }
          return $this->baseurl->out(true, $this->sort_to_params($newsort));
      }
code: public function new_sort_url($sort, $newsortreverse) {
          if ($newsortreverse) {
              $order = -1;
          } else {
              $order = 1;
          }
          // Tricky code to add the new sort at the start, removing it from where it was before, if it was present.
          $newsort = array_reverse($this->sort);
          if (isset($newsort[$sort])) {
              unset($newsort[$sort]);
          }
          $newsort[$sort] = $order;
          $newsort = array_reverse($newsort);
          if (count($newsort) > self::MAX_SORTS) {
              $newsort = array_slice($newsort, 0, self::MAX_SORTS, true);
          }
          return $this->baseurl->out(true, $this->sort_to_params($newsort));
      }
code_tokens: public function new_sort_url ( $ sort , $ newsortreverse ) { if ( $ newsortreverse ) { $ order = - 1 ; } else { $ order = 1 ; } // Tricky code to add the new sort at the start, removing it from where it was before, if it was present. $ newsort = array_reverse ( $ this -> sort ) ; if ( isset ( $ newsort [ $ sort ] ) ) { unset ( $ newsort [ $ sort ] ) ; } $ newsort [ $ sort ] = $ order ; $ newsort = array_reverse ( $ newsort ) ; if ( count ( $ newsort ) > self :: MAX_SORTS ) { $ newsort = array_slice ( $ newsort , 0 , self :: MAX_SORTS , true ) ; } return $ this -> baseurl -> out ( true , $ this -> sort_to_params ( $ newsort ) ) ; }
docstring: Get a URL to redisplay the page with a new sort for the question bank.
  @param string $sort the column, or column_subsort to sort on.
  @param bool $newsortreverse whether to sort in reverse order.
  @return string The new URL.
docstring_tokens: Get a URL to redisplay the page with a new sort for the question bank .