Custom Tag Order Output

Hello everybody.
I like to sort those $typs in a custom order.

<?php 
  $typs = $projekte->pluck('typologie', ',', true);
?>
<?php foreach ($typs as $typ): ?>
  ((foo))
<?php endforeach ?>

Preferably as they are listed in the tag field “typologie” in the blueprint. Alternatively directly in the template ala sortBy(‘b’, ‘a’, ‘d’, ‘c’). Is that possible? — Depends on what is easier.

You could use array_intersect, with $page->typologie()->split() as first argument, and $types as second, which will return an array with all items from the first array that are also present in the second array, in the order of the first argument.

Many thanks for the valuable tip. :pray:

I now had a look at a few examples in the forum under the search term array_intersect.
This is what the final solution looks like.
Any suggestions for optimisation?

<?php 
  $order = [
    'Arbeiten',
    'Wohnen',
    'Innenraum',
    'Kultur',
    'Öffentlicher Raum',
  ];

  $typologie = $projekte->pluck('typologie', ',', true);
  
  $types = array_intersect($order, $typologie);

?>
<?php foreach ($types as $typ): ?>
  ((foo))
<?php endforeach ?>