sort a repeater field values by last name code example
Example: sort acf repeater field alphabetically
<?php
$repeater = get_field('traditional_dining');
foreach ($repeater as $key => $row) {
$the_website[$key] = $row['website'];
$the_name[$key] = $row['name'];
$the_address[$key] = $row['address'];
$the_phone_number[$key] = $row['phone_number'];
$the_map_url[$key] = $row['map_url'];
}
array_multisort($the_name, SORT_ASC, $repeater);
foreach( $repeater as $row ) { ?>
<div class="biz-module">
<h2><a href="<?php echo $row['website']; ?>" title="Visit the website for <?php echo $row['website']; ?>"><?php echo $row['name']; ?></a></h2>
<h3><a href="<?php echo $row['map_url']; ?>" title="Find <?php echo $row['name']; ?> on the map"><?php echo $row['address']; ?></a></h3>
<h4><?php echo $row['phone_number']; ?></h4>
</div>
<?php } ?>