original_string: public function sortPlugins(array $plugins)
      {
          $global = $this->getPluginsBundledWithPiwik();
          if (empty($global)) {
              return $plugins;
          }
  
          // we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin
          $global = array_merge($global, $this->corePluginsDisabledByDefault);
  
          $global = array_values($global);
          $plugins = array_values($plugins);
  
          $defaultPluginsLoadedFirst = array_intersect($global, $plugins);
  
          $otherPluginsToLoadAfterDefaultPlugins = array_diff($plugins, $defaultPluginsLoadedFirst);
  
          // sort by name to have a predictable order for those extra plugins
          natcasesort($otherPluginsToLoadAfterDefaultPlugins);
  
          $sorted = array_merge($defaultPluginsLoadedFirst, $otherPluginsToLoadAfterDefaultPlugins);
  
          return $sorted;
      }
code: public function sortPlugins(array $plugins)
      {
          $global = $this->getPluginsBundledWithPiwik();
          if (empty($global)) {
              return $plugins;
          }
  
          // we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin
          $global = array_merge($global, $this->corePluginsDisabledByDefault);
  
          $global = array_values($global);
          $plugins = array_values($plugins);
  
          $defaultPluginsLoadedFirst = array_intersect($global, $plugins);
  
          $otherPluginsToLoadAfterDefaultPlugins = array_diff($plugins, $defaultPluginsLoadedFirst);
  
          // sort by name to have a predictable order for those extra plugins
          natcasesort($otherPluginsToLoadAfterDefaultPlugins);
  
          $sorted = array_merge($defaultPluginsLoadedFirst, $otherPluginsToLoadAfterDefaultPlugins);
  
          return $sorted;
      }
code_tokens: public function sortPlugins ( array $ plugins ) { $ global = $ this -> getPluginsBundledWithPiwik ( ) ; if ( empty ( $ global ) ) { return $ plugins ; } // we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin $ global = array_merge ( $ global , $ this -> corePluginsDisabledByDefault ) ; $ global = array_values ( $ global ) ; $ plugins = array_values ( $ plugins ) ; $ defaultPluginsLoadedFirst = array_intersect ( $ global , $ plugins ) ; $ otherPluginsToLoadAfterDefaultPlugins = array_diff ( $ plugins , $ defaultPluginsLoadedFirst ) ; // sort by name to have a predictable order for those extra plugins natcasesort ( $ otherPluginsToLoadAfterDefaultPlugins ) ; $ sorted = array_merge ( $ defaultPluginsLoadedFirst , $ otherPluginsToLoadAfterDefaultPlugins ) ; return $ sorted ; }
docstring: Sorts an array of plugins in the order they should be loaded. We cannot use DI here as DI is not initialized
  at this stage.
  
  @params string[] $plugins
  @return \string[]
docstring_tokens: Sorts an array of plugins in the order they should be loaded . We cannot use DI here as DI is not initialized at this stage .