original_string: public static function sort_qtype_array($qtypes, $config = null) {
          if (is_null($config)) {
              $config = self::get_config();
          }
  
          $sortorder = array();
          $otherqtypes = array();
          foreach ($qtypes as $name => $localname) {
              $sortvar = $name . '_sortorder';
              if (isset($config->$sortvar)) {
                  $sortorder[$config->$sortvar] = $name;
              } else {
                  $otherqtypes[$name] = $localname;
              }
          }
  
          ksort($sortorder);
          core_collator::asort($otherqtypes);
  
          $sortedqtypes = array();
          foreach ($sortorder as $name) {
              $sortedqtypes[$name] = $qtypes[$name];
          }
          foreach ($otherqtypes as $name => $notused) {
              $sortedqtypes[$name] = $qtypes[$name];
          }
          return $sortedqtypes;
      }
code: public static function sort_qtype_array($qtypes, $config = null) {
          if (is_null($config)) {
              $config = self::get_config();
          }
  
          $sortorder = array();
          $otherqtypes = array();
          foreach ($qtypes as $name => $localname) {
              $sortvar = $name . '_sortorder';
              if (isset($config->$sortvar)) {
                  $sortorder[$config->$sortvar] = $name;
              } else {
                  $otherqtypes[$name] = $localname;
              }
          }
  
          ksort($sortorder);
          core_collator::asort($otherqtypes);
  
          $sortedqtypes = array();
          foreach ($sortorder as $name) {
              $sortedqtypes[$name] = $qtypes[$name];
          }
          foreach ($otherqtypes as $name => $notused) {
              $sortedqtypes[$name] = $qtypes[$name];
          }
          return $sortedqtypes;
      }
code_tokens: public static function sort_qtype_array ( $ qtypes , $ config = null ) { if ( is_null ( $ config ) ) { $ config = self :: get_config ( ) ; } $ sortorder = array ( ) ; $ otherqtypes = array ( ) ; foreach ( $ qtypes as $ name => $ localname ) { $ sortvar = $ name . '_sortorder' ; if ( isset ( $ config -> $ sortvar ) ) { $ sortorder [ $ config -> $ sortvar ] = $ name ; } else { $ otherqtypes [ $ name ] = $ localname ; } } ksort ( $ sortorder ) ; core_collator :: asort ( $ otherqtypes ) ; $ sortedqtypes = array ( ) ; foreach ( $ sortorder as $ name ) { $ sortedqtypes [ $ name ] = $ qtypes [ $ name ] ; } foreach ( $ otherqtypes as $ name => $ notused ) { $ sortedqtypes [ $ name ] = $ qtypes [ $ name ] ; } return $ sortedqtypes ; }
docstring: Sort an array of question types according to the order the admin set up,
  and then alphabetically for the rest.
  @param array qtype->name() => qtype->local_name().
  @return array sorted array.
docstring_tokens: Sort an array of question types according to the order the admin set up and then alphabetically for the rest .