Sort records by date inside Foreach Loop
I need to sort all my records inside of a foreach loop by date. I know this can be done using 'orderBy' => 'date ASC', but I can use that function in this scenario, and I need to sort the records by date inside, or just before the foreach loop. Anyone have any suggestions?
<?php foreach ($mediaRecords as $record): ?>
<?php sort($record['date'] ='ASC'); ?>
<?php foreach ($record['media'] as $index => $upload): ?>
<img src="<?php echo $upload['thumbUrlPath2'] ?>" alt="<?php echo htmlencode($record['title']) ?>" />
<?php endforeach; ?>
<?php endforeach ?>