what you were looking for..... usort()
how to use it...
<?
function sort_names_by_sur($a, $b)
{
list(, $last_a) = explode(' ',$a); //ditch first name for comparison, use last name only
list(, $last_b) = exlpode(' ',$b); //same as above but for name b
if ($a == $b)
{
return 0; //if they are equal, leave them in current order
}
return ($a < $b) ? -1 : 1; //move respectively if less than or greater than
}
$author = array(
"Bruno Aliotta",
"Steve Mitchell",
"Derrick M. Hussey");
usort($author, 'sort_names_by_sur'); //sort using your custom sort function
that will use a custom defined sorting function to sort by last name...
this would return:
$author as:
array(
"Bruno Aliotta",
"Derrick M. Hussey",
"Steve Mitchell")