Change order of breadcrumbs elements in hook hook_system_breadcrumb_alter I want to add another element to breadcrumb.
I have:
Home &gt; Node Title
I want to add another link between the two elements like:
Home &gt; Link to view &gt; Node Title 

I have tried with hook_system_breadcrumb_alter like the following:

/**
 * Implements hook_system_breadcrumb_alter().
 */
function MyModules_system_breadcrumb_alter(Breadcrumb &amp;$breadcrumb, RouteMatchInterface $route_match, array $context) {
  if ( $route_match-&gt;getRouteName() === 'entity.node.canonical'){
   $node = $route_match-&gt;getParameter('node');
   if ($node instanceof  Drupal\node\Entity\Node &amp;&amp; $node-&gt;getType() === 'my_node_type'){
     // Get the listing view url.
     $listing_url = Url::fromRoute('view.my_view_id.my_display_id');
     // Add the listing url to breadcrumbs.
     $breadcrumb-&gt;addLink(Link::fromTextAndUrl(t('Link to view'), $listing_url));
   }
  }
}


But i get Home &gt; Node Title &gt; Link to view instead of Home &gt; Link to view &gt; Node Title
My question is how can i change the order of the last two breadcrumbs elements?
Create a new breadcrumb instance:

$links = $breadcrumb-&gt;getLinks();
// change order of $links
$cacheability = \Drupal\Core\Cache\CacheableMetadata::createFromObject($breadcrumb);
$breadcrumb = new \Drupal\Core\Breadcrumb\Breadcrumb();
$breadcrumb-&gt;setLinks($links);
$breadcrumb-&gt;addCacheableDependency($cacheability);