original_string: private function findAndSortTags($tagName, ContainerBuilder $container)
      {
          $sortedTags = [];
  
          foreach ($container->findTaggedServiceIds($tagName, true) as $serviceId => $tags) {
              foreach ($tags as $attributes) {
                  $priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
                  $sortedTags[$priority][] = [$serviceId, $attributes];
              }
          }
  
          if ($sortedTags) {
              krsort($sortedTags);
              $sortedTags = array_merge(...$sortedTags);
          }
  
          return $sortedTags;
      }
code: private function findAndSortTags($tagName, ContainerBuilder $container)
      {
          $sortedTags = [];
  
          foreach ($container->findTaggedServiceIds($tagName, true) as $serviceId => $tags) {
              foreach ($tags as $attributes) {
                  $priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
                  $sortedTags[$priority][] = [$serviceId, $attributes];
              }
          }
  
          if ($sortedTags) {
              krsort($sortedTags);
              $sortedTags = array_merge(...$sortedTags);
          }
  
          return $sortedTags;
      }
code_tokens: private function findAndSortTags ( $ tagName , ContainerBuilder $ container ) { $ sortedTags = [ ] ; foreach ( $ container -> findTaggedServiceIds ( $ tagName , true ) as $ serviceId => $ tags ) { foreach ( $ tags as $ attributes ) { $ priority = isset ( $ attributes [ 'priority' ] ) ? $ attributes [ 'priority' ] : 0 ; $ sortedTags [ $ priority ] [ ] = [ $ serviceId , $ attributes ] ; } } if ( $ sortedTags ) { krsort ( $ sortedTags ) ; $ sortedTags = array_merge ( ... $ sortedTags ) ; } return $ sortedTags ; }
docstring: Finds and orders all service tags with the given name by their priority.
  
  The order of additions must be respected for services having the same priority,
  and knowing that the \SplPriorityQueue class does not respect the FIFO method,
  we should not use this class.
  
  @see https://bugs.php.net/bug.php?id=53710
  @see https://bugs.php.net/bug.php?id=60926
  
  @param string           $tagName
  @param ContainerBuilder $container
  
  @return array
docstring_tokens: Finds and orders all service tags with the given name by their priority .