original_string: protected function reorder_plugin_types(array $types) {
          $fix = array('mod' => $types['mod']);
          foreach (core_component::get_plugin_list('mod') as $plugin => $fulldir) {
              if (!$subtypes = core_component::get_subplugins('mod_'.$plugin)) {
                  continue;
              }
              foreach ($subtypes as $subtype => $ignored) {
                  $fix[$subtype] = $types[$subtype];
              }
          }
  
          $fix['mod']        = $types['mod'];
          $fix['block']      = $types['block'];
          $fix['qtype']      = $types['qtype'];
          $fix['qbehaviour'] = $types['qbehaviour'];
          $fix['qformat']    = $types['qformat'];
          $fix['filter']     = $types['filter'];
  
          $fix['editor']     = $types['editor'];
          foreach (core_component::get_plugin_list('editor') as $plugin => $fulldir) {
              if (!$subtypes = core_component::get_subplugins('editor_'.$plugin)) {
                  continue;
              }
              foreach ($subtypes as $subtype => $ignored) {
                  $fix[$subtype] = $types[$subtype];
              }
          }
  
          $fix['enrol'] = $types['enrol'];
          $fix['auth']  = $types['auth'];
          $fix['tool']  = $types['tool'];
          foreach (core_component::get_plugin_list('tool') as $plugin => $fulldir) {
              if (!$subtypes = core_component::get_subplugins('tool_'.$plugin)) {
                  continue;
              }
              foreach ($subtypes as $subtype => $ignored) {
                  $fix[$subtype] = $types[$subtype];
              }
          }
  
          foreach ($types as $type => $path) {
              if (!isset($fix[$type])) {
                  $fix[$type] = $path;
              }
          }
          return $fix;
      }
code: protected function reorder_plugin_types(array $types) {
          $fix = array('mod' => $types['mod']);
          foreach (core_component::get_plugin_list('mod') as $plugin => $fulldir) {
              if (!$subtypes = core_component::get_subplugins('mod_'.$plugin)) {
                  continue;
              }
              foreach ($subtypes as $subtype => $ignored) {
                  $fix[$subtype] = $types[$subtype];
              }
          }
  
          $fix['mod']        = $types['mod'];
          $fix['block']      = $types['block'];
          $fix['qtype']      = $types['qtype'];
          $fix['qbehaviour'] = $types['qbehaviour'];
          $fix['qformat']    = $types['qformat'];
          $fix['filter']     = $types['filter'];
  
          $fix['editor']     = $types['editor'];
          foreach (core_component::get_plugin_list('editor') as $plugin => $fulldir) {
              if (!$subtypes = core_component::get_subplugins('editor_'.$plugin)) {
                  continue;
              }
              foreach ($subtypes as $subtype => $ignored) {
                  $fix[$subtype] = $types[$subtype];
              }
          }
  
          $fix['enrol'] = $types['enrol'];
          $fix['auth']  = $types['auth'];
          $fix['tool']  = $types['tool'];
          foreach (core_component::get_plugin_list('tool') as $plugin => $fulldir) {
              if (!$subtypes = core_component::get_subplugins('tool_'.$plugin)) {
                  continue;
              }
              foreach ($subtypes as $subtype => $ignored) {
                  $fix[$subtype] = $types[$subtype];
              }
          }
  
          foreach ($types as $type => $path) {
              if (!isset($fix[$type])) {
                  $fix[$type] = $path;
              }
          }
          return $fix;
      }
code_tokens: protected function reorder_plugin_types ( array $ types ) { $ fix = array ( 'mod' => $ types [ 'mod' ] ) ; foreach ( core_component :: get_plugin_list ( 'mod' ) as $ plugin => $ fulldir ) { if ( ! $ subtypes = core_component :: get_subplugins ( 'mod_' . $ plugin ) ) { continue ; } foreach ( $ subtypes as $ subtype => $ ignored ) { $ fix [ $ subtype ] = $ types [ $ subtype ] ; } } $ fix [ 'mod' ] = $ types [ 'mod' ] ; $ fix [ 'block' ] = $ types [ 'block' ] ; $ fix [ 'qtype' ] = $ types [ 'qtype' ] ; $ fix [ 'qbehaviour' ] = $ types [ 'qbehaviour' ] ; $ fix [ 'qformat' ] = $ types [ 'qformat' ] ; $ fix [ 'filter' ] = $ types [ 'filter' ] ; $ fix [ 'editor' ] = $ types [ 'editor' ] ; foreach ( core_component :: get_plugin_list ( 'editor' ) as $ plugin => $ fulldir ) { if ( ! $ subtypes = core_component :: get_subplugins ( 'editor_' . $ plugin ) ) { continue ; } foreach ( $ subtypes as $ subtype => $ ignored ) { $ fix [ $ subtype ] = $ types [ $ subtype ] ; } } $ fix [ 'enrol' ] = $ types [ 'enrol' ] ; $ fix [ 'auth' ] = $ types [ 'auth' ] ; $ fix [ 'tool' ] = $ types [ 'tool' ] ; foreach ( core_component :: get_plugin_list ( 'tool' ) as $ plugin => $ fulldir ) { if ( ! $ subtypes = core_component :: get_subplugins ( 'tool_' . $ plugin ) ) { continue ; } foreach ( $ subtypes as $ subtype => $ ignored ) { $ fix [ $ subtype ] = $ types [ $ subtype ] ; } } foreach ( $ types as $ type => $ path ) { if ( ! isset ( $ fix [ $ type ] ) ) { $ fix [ $ type ] = $ path ; } } return $ fix ; }
docstring: Reorders plugin types into a sequence to be displayed
  
  For technical reasons, plugin types returned by {@link core_component::get_plugin_types()} are
  in a certain order that does not need to fit the expected order for the display.
  Particularly, activity modules should be displayed first as they represent the
  real heart of Moodle. They should be followed by other plugin types that are
  used to build the courses (as that is what one expects from LMS). After that,
  other supportive plugin types follow.
  
  @param array $types associative array
  @return array same array with altered order of items
docstring_tokens: Reorders plugin types into a sequence to be displayed