You can use Php’s usort()
function with a callback. For example, if you want to sort images by ID, you could try something like this (stealing the filter that @Milo used in their answer):
<?php
function sort_callback($a,$b)
{
if ($a['id'] == $b['id']) {
return 0;
}
return ($a['id'] < $b['id']) ? -1 : 1;
}
function my_acf_load_field( $field ){
usort( $field, 'sort_callback');
return $field;
}
add_filter( 'acf_load_field-gallery', 'my_acf_load_field' );
You can adjust the sort_callback
function to sort by whichever value in the $image array that you’d like.