I have this code that generates a list with products and prices , this list is showed without order and I am trying to order it by price.
I have used asort($items) to get this done but it did not work, I do not know why.
Here is the code, any help is appreciated:
<?php $currencyd = 'U$S'; asort($items);?>
<?php foreach ($items as $key => $item): ?>
<a rel="nofollow" class="list-group-item" target="_blank"
href=" <?php echo esc_url($item['url']) ?>"
<?php echo $item['ga_event'] ?>
<img src="<?php echo esc_attr(TemplateHelper::getMerhantIconUrl($item, false)); ?>" />
<?php echo \esc_html($item['domain']); ?>
<?php if ($item['price']): ?>
<span style="background-color: #575354;" class="cegg-price cegg-price-badge">
<?php echo TemplateHelper::formatPriceCurrency($item['price_raw'], $currencyd ); ?></span>
<?php endif; ?>
</a>
<?php endforeach; ?>
Thanks